Skip to content

Commit 2e57356

Browse files
rohandebsarkarpecey
authored andcommitted
Add support for nav_order and Fix hardcoded navbar titles (alshedivat#664)
1 parent 88f7d38 commit 2e57356

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

_includes/header.html

+13-7
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,33 @@
9191
<div class="collapse navbar-collapse text-right" id="navbarNav">
9292
<ul class="navbar-nav ml-auto flex-nowrap">
9393

94+
{%- for page in site.pages -%}
95+
{% if page.permalink == '/' %}
96+
{% assign about_title = page.title %}
97+
{% endif %}
98+
{% endfor %}
99+
94100
<!-- About -->
95-
<li class="nav-item {% if page.title == 'about' %}active{% endif %}">
96-
<a class="nav-link" href="{{ '/' | relative_url }}">about
97-
{%- if page.title == "about" -%}
101+
<li class="nav-item {% if page.permalink == '/' %}active{% endif %}">
102+
<a class="nav-link" href="{{ '/' | relative_url }}">{{ about_title }}
103+
{%- if page.permalink == '/' -%}
98104
<span class="sr-only">(current)</span>
99105
{%- endif -%}
100106
</a>
101107
</li>
102-
{% if site.blog_name %}
108+
{% if site.blog_nav_title %}
103109
<!-- Blog -->
104110
<li class="nav-item {% if page.url contains 'blog' %}active{% endif %}">
105-
<a class="nav-link" href="{{ '/blog/' | relative_url }}">blog
106-
{%- if page.title == "blog" -%}
111+
<a class="nav-link" href="{{ '/blog/' | relative_url }}">{{ site.blog_nav_title }}
112+
{%- if page.url contains 'blog' -%}
107113
<span class="sr-only">(current)</span>
108114
{%- endif -%}
109115
</a>
110116
</li>
111117
{%- endif %}
112118

113119
<!-- Other pages -->
114-
{%- assign sorted_pages = site.pages | sort: "title" -%}
120+
{%- assign sorted_pages = site.pages | sort: "nav_order" -%}
115121
{%- for p in sorted_pages -%}
116122
{%- if p.nav and p.autogen == nil -%}
117123
{%- if p.dropdown %}

_includes/metadata.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
{%- else -%}
1919
{%- capture title -%}{{ site.title }}{%- endcapture -%}
2020
{%- endif -%}
21-
{%- if page.title != "blank" and page.url != "/" -%}
22-
{{ title }} | {{ page.title }}
21+
{% if page.url == '/blog/index.html' %}
22+
{{ site.blog_nav_title }} | {{ title }}
23+
{%- elsif page.title != "blank" and page.url != "/" -%}
24+
{{ page.title }} | {{ title }}
2325
{%- else -%}
2426
{{ title }}
2527
{%- endif -%}

_pages/dropdown.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: page
33
title: submenus
44
nav: true
5+
nav_order: 3
56
dropdown: true
67
children:
78
- title: publications

0 commit comments

Comments
 (0)