Add support for folder urls in the sidebar.

If present, clicking the folder goes to the URL itself. Toggling the folder requires
clicking the toggle arrow precisely. If URL is omitted, the whole folder title
works as a toggle.
This commit is contained in:
Spencer Bliven
2019-06-17 11:40:04 +02:00
parent c0626c4884
commit 9a7b8710ba
3 changed files with 17 additions and 27 deletions

View File

@ -23,8 +23,8 @@ to _config.yml, which requires restarting the webserver).
Building locally requires ruby 2.5 and bundler. To install:
```
gem install bundler
bundle install
gem install bundler jekyll
bundle
```
To run a local webserver:

View File

@ -2,56 +2,42 @@
# Follow the pattern here for the URLs -- no slash at the beginning, and include the .html. The link here is rendered exactly as is in the Markdown references.
entries:
- product: Merlin 6
levels: one
- product: Merlin
version: 6
folders:
- title: Introduction
output: web
# URLs for top-level folders are optional. If omitted it is a bit easier to toggle the accordion.
#url: /merlin6/introduction.html
folderitems:
- title: Introduction
url: /merlin6/introduction.html
output: web
- title: Code Of Conduct
url: /merlin6/code-of-conduct.html
output: web
- title: Hardware And Software Description
url: /merlin6/hardware-and-software.html
output: web
- title: Migrating From Merlin5
url: /merlin6/migrating.html
output: web
- title: Accessing Merlin
url: /merlin6/accessing-merlin6.html
output: web
folderitems:
- title: Requesting Merlin6 Accounts
url: /merlin6/request-account.html
output: web
- title: Accessing Interactive Nodes
url: /merlin6/interactive.html
output: web
- title: Merlin6 Data Directories
url: /merlin6/data-directories.html
output: web
- title: Accessing Slurm Cluster
url: /merlin6/slurm-access.html
output: web
- title: Merlin6 Slurm
url: /merlin6/slurm.html
output: web
folderitems:
- title: Slurm Basic Commands
url: /merlin6/slurm-basics.html
output: web
- title: Slurm Configuration
url: /merlin6/slurm-configuration.html
output: web
- title: Support
output: web
folderitems:
- title: Contact
url: /merlin6/contact.html
output: web
- title: Known Problems and Troubleshooting
url: /merlin6/troubleshooting.html
output: web

View File

@ -3,12 +3,16 @@
<li class="sidebarTitle">{{sidebar[0].product}} {{sidebar[0].version}}</li>
{% for entry in sidebar %}
{% for folder in entry.folders %}
{% if folder.output contains "web" %}
{% if folder.output == nil or folder.output contains "web"%}
{% if folder.url != nil and page.url contains folder.url %}
<li class = "active" >
{% else %}
<li>
<a title="{{folder.title}}" href="#">{{folder.title}}</a>
{% endif %}
<a title="{{folder.title}}" href="{{folder.url | default:"#" }}">{{folder.title}}</a>
<ul>
{% for folderitem in folder.folderitems %}
{% if folderitem.output contains "web" %}
{% if folderitem.output == nil or folderitem.output contains "web" %}
{% if folderitem.external_url %}
<li><a title="{{folderitem.title}}" href="{{folderitem.external_url}}" target="_blank" rel="noopener">{{folderitem.title}}</a></li>
{% elsif page.url contains folderitem.url %}
@ -20,12 +24,12 @@
<li><a title="{{folderitem.title}}" href="{{folderitem.url | relative_url}}">{{folderitem.title}}</a></li>
{% endif %}
{% for subfolders in folderitem.subfolders %}
{% if subfolders.output contains "web" %}
{% if subfolders.output == nil or subfolders.output contains "web" %}
<li class="subfolders">
<a title="{{subfolders.title}}" href="#">{{ subfolders.title }}</a>
<a title="{{subfolders.title}}" href="{{subfolders.url | default:"#" }}">{{ subfolders.title }}</a>
<ul>
{% for subfolderitem in subfolders.subfolderitems %}
{% if subfolderitem.output contains "web" %}
{% if subfolderitem.output == nil or subfolderitem.output contains "web" %}
{% if subfolderitem.external_url %}
<li><a title="{{subfolderitem.title}}" href="{{subfolderitem.external_url}}" target="_blank" rel="noopener">{{subfolderitem.title}}</a></li>
{% elsif page.url == subfolderitem.url %}
@ -60,4 +64,4 @@ appear below the sidebar code above. Otherwise, if placed inside
customscripts.js, the script runs before the sidebar code runs and the
class never gets inserted.
-->
<script>$("li.active").parents('li').toggleClass("active");</script>
<script>$("li.active").parents('li').addClass("active");</script>