Skip to content
Snippets Groups Projects
Unverified Commit 2cf5c92a authored by Tom Wiesing's avatar Tom Wiesing
Browse files

Update the menu

parent b7ab7309
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,7 @@ The menu of the page is defined in the ``_config.yml`` file.
It consists of a set of items, that are defined by the following keys:
* `url` - The (internal or external) url to the page. If internal, must be relative to the root directory.
* `active` - URL to a folder under which the item should automatically be expanded (if applicable).
* `folder` - Instead of using `url`, the `folder` can be used to create a submenu pointing to a specific folder.
* `items` - A list of items for submenus.
* `external` - If set to `true`, assumes that `url` is external to the page.
......@@ -97,7 +98,7 @@ It consists of a set of items, that are defined by the following keys:
2. An item specifies the `items` key. Here the items are used accordingly.
3. An item specifies both the `folder` and `items` keys. The items for both cases are automatically merged.
Because submenus are not clickable, the `url` for submenus is ignored.
Because submenus are not clickable, the `url` for submenus is ignored when building the menu.
Furthermore, if these are mixed between folders and static items, the folders will always show first.
```yaml
......@@ -115,6 +116,9 @@ Furthermore, if these are mixed between folders and static items, the folders wi
url: 'https://cs.fau.de/'
```
A submenu is automatically expanded if any of the submenu items inside it are clicked.
Alternatively, if the menu item contains an `active` key, it is checked as well.
### Working locally
If you want to do more than the occasional editing, you'll soon realise GitHub's editor and preview are too limited.
......
permalink: pretty
permalink: /news/:year/:month/:day/:title/
# Setup
title: KWARC
......@@ -11,7 +11,6 @@ paginate_path: "/news/page:num/"
blog_path: "/news/"
future: True
gems:
- jemoji
- jekyll-paginate
- jekyll-github-metadata
- jekyll-redirect-from
......@@ -44,7 +43,10 @@ fontawesome: font-awesome-4.7.0
menu:
- title: 'News'
url: '/news/'
active: '/news/'
- title: 'People'
active: '/people/'
items:
- title: 'Current Members'
url: '/people/'
......
......@@ -2,8 +2,27 @@
This page creates a single (non-submenu) item. It expects `item` as a variable.
{% endcomment %}
{% assign menu_active = false %}
{% assign base_folder = page.url | split: '/' %}
{% assign base_folder = base_folder[1] %}
{% assign represents = item.active | split: '/' %}
{% assign represents = represents[1] %}
{% if represents %}
{% if base_folder == represents %}
{% assign menu_active = true %}
{% endif %}
{% endif %}
{% if page.url == item.url %}
{% assign menu_active = true %}
{% endif %}
{% unless item.menu_hidden %}
<li
{% if menu_active %}class="active"{% endif %}
{% if page.url == item.url %}class="active"{% endif %}
>
{% if item.external %}
......
......@@ -5,21 +5,37 @@
{% unless item.menu_hidden %}
{% assign base_folder = page.url | split: '/' %}
<!-- if we are in the right folder, we are active -->
{% if base_folder[1] == item.folder %}
{% assign menu_active = true %}
{% else %}
{% assign menu_active = false %}
{% for item in (item.items | where: "url", page.url) %}
{% unless item.external %}
{% assign base_folder = base_folder[1] %}
{% assign represents = item.active | split: '/' %}
{% assign represents = represents[1] %}
{% assign menu_active = false %}
{% if base_folder %}
{% if item.folder %}
{% if base_folder == item.folder %}
{% assign menu_active = true %}
<!-- active because {{item}} -->
{% endunless %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% if represents %}
{% if base_folder == represents %}
{% assign menu_active = true %}
{% endif %}
{% endif %}
{% unless menu_active %}
{% for it in item.items %}
{% if page.url == it.url %}
{% unless it.external %}
{% assign menu_active = true %}
{% endunless %}
{% endif %}
{% endfor %}
{% endunless %}
<!-- Find the current folder -->
{% assign item_folder = item.folder %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment