Skip to content

Commit

Permalink
Add support for nav_order and Fix hardcoded navbar titles (alshediv…
Browse files Browse the repository at this point in the history
  • Loading branch information
rohandebsarkar authored and pecey committed Jan 27, 2023
1 parent 88f7d38 commit 2e57356
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
20 changes: 13 additions & 7 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,33 @@
<div class="collapse navbar-collapse text-right" id="navbarNav">
<ul class="navbar-nav ml-auto flex-nowrap">

{%- for page in site.pages -%}
{% if page.permalink == '/' %}
{% assign about_title = page.title %}
{% endif %}
{% endfor %}

<!-- About -->
<li class="nav-item {% if page.title == 'about' %}active{% endif %}">
<a class="nav-link" href="{{ '/' | relative_url }}">about
{%- if page.title == "about" -%}
<li class="nav-item {% if page.permalink == '/' %}active{% endif %}">
<a class="nav-link" href="{{ '/' | relative_url }}">{{ about_title }}
{%- if page.permalink == '/' -%}
<span class="sr-only">(current)</span>
{%- endif -%}
</a>
</li>
{% if site.blog_name %}
{% if site.blog_nav_title %}
<!-- Blog -->
<li class="nav-item {% if page.url contains 'blog' %}active{% endif %}">
<a class="nav-link" href="{{ '/blog/' | relative_url }}">blog
{%- if page.title == "blog" -%}
<a class="nav-link" href="{{ '/blog/' | relative_url }}">{{ site.blog_nav_title }}
{%- if page.url contains 'blog' -%}
<span class="sr-only">(current)</span>
{%- endif -%}
</a>
</li>
{%- endif %}

<!-- Other pages -->
{%- assign sorted_pages = site.pages | sort: "title" -%}
{%- assign sorted_pages = site.pages | sort: "nav_order" -%}
{%- for p in sorted_pages -%}
{%- if p.nav and p.autogen == nil -%}
{%- if p.dropdown %}
Expand Down
6 changes: 4 additions & 2 deletions _includes/metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
{%- else -%}
{%- capture title -%}{{ site.title }}{%- endcapture -%}
{%- endif -%}
{%- if page.title != "blank" and page.url != "/" -%}
{{ title }} | {{ page.title }}
{% if page.url == '/blog/index.html' %}
{{ site.blog_nav_title }} | {{ title }}
{%- elsif page.title != "blank" and page.url != "/" -%}
{{ page.title }} | {{ title }}
{%- else -%}
{{ title }}
{%- endif -%}
Expand Down
1 change: 1 addition & 0 deletions _pages/dropdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
layout: page
title: submenus
nav: true
nav_order: 3
dropdown: true
children:
- title: publications
Expand Down

0 comments on commit 2e57356

Please sign in to comment.