-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist-sections.html
23 lines (20 loc) · 987 Bytes
/
list-sections.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{% comment %}
List directories which are in the current directory.
The logic is: after removing the **common** part of the item's path,
we use an item if goes exactly **one** level down i.e. direct descendants.
Unfortunately Jekyll doesn't have a concept of directories, just pages in site.pages,
so here we use the presence of index.md to indicate that is the index of a directory.
This also makes sense to use this approach because Jekyll needs to actually have an HTML page
to reference as the directory menu.
Just make sure you have index.md in each directory and that it uses the listing layout.
{% endcomment %}
<ul>
{% for item in site.pages %}
{% assign item_crumbs = item.url | remove_first: page.dir | split: '/' %}
{% if item_crumbs.size == 1 and item.name == 'index.md' %}
<li>
<a href="{{ item.url | relative_url }}">{{ item.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>