Skip to content

Commit f3a86e2

Browse files
committed
nav-bar: limit nav links to pages with nav-links
This way, if you have a folder full of pages, but only some of those pages belong in the navigation, then only those pages declare nav-links and those are the ones that are included in the navigation.
1 parent 3c6c255 commit f3a86e2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

_includes/layout/nav-bar

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ A horizontal navigation bar with links.
2121
{%- assign links = "" -%}
2222
{%- for p in candidates -%}
2323
{%- capture p-dir -%} {%- include util/dir path=p.url -%} {%- endcapture -%}
24-
{%- if p-dir == page-dir -%}
25-
{%- comment -%} Sort index page before the others. {%- endcomment -%}
26-
{%- assign url = p.url | replace: "/index", "/!index" -%}
27-
{%- assign title = p.nav-title | default: p.title
28-
| replace: " ", " " | replace: "-", "‑" -%}
29-
{%- capture link -%}
30-
<li><a href="{{url}}">{{title}}</a></li>
31-
{%- endcapture -%}
32-
{%- unless links == "" -%}
33-
{%- assign links = links | append: "|" -%}
34-
{%- endunless -%}
35-
{%- assign links = links | append: link -%}
36-
{%- endif -%}
24+
{%- if p-dir != page-dir -%} {%- continue -%} {%- endif -%}
25+
{%- unless p.nav-links -%} {%- continue -%} {%- endunless -%}
26+
27+
{%- comment -%} Sort index page before the others. {%- endcomment -%}
28+
{%- assign url = p.url | replace: "/index", "/!index" -%}
29+
30+
{%- assign title = p.nav-title | default: p.title
31+
| replace: " ", "&nbsp;" | replace: "-", "&#8209;" -%}
32+
{%- capture link -%}
33+
<li><a href="{{url}}">{{title}}</a></li>
34+
{%- endcapture -%}
35+
{%- unless links == "" -%}
36+
{%- assign links = links | append: "|" -%}
37+
{%- endunless -%}
38+
{%- assign links = links | append: link -%}
3739
{%- endfor -%}
3840

3941
{%- comment -%}

0 commit comments

Comments
 (0)