Add support for `nav_order` and Fix hardcoded navbar titles (#664)

This commit is contained in:
Rohan Deb Sarkar 2022-05-13 00:37:04 +05:30 committed by GitHub
parent 503bfc235a
commit 8db7daf356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 11 deletions

View File

@ -84,7 +84,8 @@ panelbear_analytics: # panelbear analytics site ID (format: XXXXXXXXX)
# Blog # Blog
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
blog_name: al-folio # your blog must have a name for it to show up in the nav bar blog_name: al-folio # blog_name will be displayed in your blog page
blog_nav_title: blog # your blog must have a title for it to be displayed in the nav bar
blog_description: a simple whitespace theme for academics blog_description: a simple whitespace theme for academics
permalink: /blog/:year/:title/ permalink: /blog/:year/:title/

View File

@ -4,7 +4,7 @@
<!-- Nav Bar --> <!-- Nav Bar -->
<nav id="navbar" class="navbar navbar-light navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}"> <nav id="navbar" class="navbar navbar-light navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}">
<div class="container"> <div class="container">
{% if page.title != "about" -%} {% if page.permalink != '/' -%}
<a class="navbar-brand title font-weight-lighter" href="{{ site.baseurl | prepend: site.url }}/"> <a class="navbar-brand title font-weight-lighter" href="{{ site.baseurl | prepend: site.url }}/">
{%- if site.title == "blank" -%}<span class="font-weight-bold">{{ site.first_name }}</span> {{ site.middle_name }} {{ site.last_name }}{%- else -%}{{ site.title }}{%- endif -%} {%- if site.title == "blank" -%}<span class="font-weight-bold">{{ site.first_name }}</span> {{ site.middle_name }} {{ site.last_name }}{%- else -%}{{ site.title }}{%- endif -%}
</a> </a>
@ -25,19 +25,25 @@
<div class="collapse navbar-collapse text-right" id="navbarNav"> <div class="collapse navbar-collapse text-right" id="navbarNav">
<ul class="navbar-nav ml-auto flex-nowrap"> <ul class="navbar-nav ml-auto flex-nowrap">
{%- for page in site.pages -%}
{% if page.permalink == '/' %}
{% assign about_title = page.title %}
{% endif %}
{% endfor %}
<!-- About --> <!-- About -->
<li class="nav-item {% if page.title == 'about' %}active{% endif %}"> <li class="nav-item {% if page.permalink == '/' %}active{% endif %}">
<a class="nav-link" href="{{ '/' | relative_url }}">about <a class="nav-link" href="{{ '/' | relative_url }}">{{ about_title }}
{%- if page.title == "about" -%} {%- if page.permalink == '/' -%}
<span class="sr-only">(current)</span> <span class="sr-only">(current)</span>
{%- endif -%} {%- endif -%}
</a> </a>
</li> </li>
{% if site.blog_name %} {% if site.blog_nav_title %}
<!-- Blog --> <!-- Blog -->
<li class="nav-item {% if page.url contains 'blog' %}active{% endif %}"> <li class="nav-item {% if page.url contains 'blog' %}active{% endif %}">
<a class="nav-link" href="{{ '/blog/' | relative_url }}">blog <a class="nav-link" href="{{ '/blog/' | relative_url }}">{{ site.blog_nav_title }}
{%- if page.title == "blog" -%} {%- if page.url contains 'blog' -%}
<span class="sr-only">(current)</span> <span class="sr-only">(current)</span>
{%- endif -%} {%- endif -%}
</a> </a>
@ -45,7 +51,7 @@
{%- endif %} {%- endif %}
<!-- Other pages --> <!-- Other pages -->
{%- assign sorted_pages = site.pages | sort: "title" -%} {%- assign sorted_pages = site.pages | sort: "nav_order" -%}
{%- for p in sorted_pages -%} {%- for p in sorted_pages -%}
{%- if p.nav and p.autogen == nil -%} {%- if p.nav and p.autogen == nil -%}
{%- if p.dropdown %} {%- if p.dropdown %}

View File

@ -18,8 +18,10 @@
{%- else -%} {%- else -%}
{%- capture title -%}{{ site.title }}{%- endcapture -%} {%- capture title -%}{{ site.title }}{%- endcapture -%}
{%- endif -%} {%- endif -%}
{%- if page.title != "blank" and page.url != "/" -%} {% if page.url == '/blog/index.html' %}
{{ title }} | {{ page.title }} {{ site.blog_nav_title }} | {{ title }}
{%- elsif page.title != "blank" and page.url != "/" -%}
{{ page.title }} | {{ title }}
{%- else -%} {%- else -%}
{{ title }} {{ title }}
{%- endif -%} {%- endif -%}

View File

@ -2,6 +2,7 @@
layout: page layout: page
title: submenus title: submenus
nav: true nav: true
nav_order: 3
dropdown: true dropdown: true
children: children:
- title: publications - title: publications

View File

@ -4,6 +4,7 @@ title: projects
permalink: /projects/ permalink: /projects/
description: A growing collection of your cool projects. description: A growing collection of your cool projects.
nav: true nav: true
nav_order: 1
display_categories: [work, fun] display_categories: [work, fun]
horizontal: false horizontal: false
--- ---

View File

@ -5,6 +5,7 @@ title: publications
description: publications by categories in reversed chronological order. generated by jekyll-scholar. description: publications by categories in reversed chronological order. generated by jekyll-scholar.
years: [1956, 1950, 1935, 1905] years: [1956, 1950, 1935, 1905]
nav: true nav: true
nav_order: 2
--- ---
<!-- _pages/publications.md --> <!-- _pages/publications.md -->
<div class="publications"> <div class="publications">

View File

@ -4,6 +4,7 @@ permalink: /teaching/
title: teaching title: teaching
description: Materials for courses you taught. Replace this text with your description. description: Materials for courses you taught. Replace this text with your description.
nav: true nav: true
nav_order: 2
--- ---
For now, this page is assumed to be a static description of your courses. You can convert it to a collection similar to `_projects/` so that you can have a dedicated page for each course. For now, this page is assumed to be a static description of your courses. You can convert it to a collection similar to `_projects/` so that you can have a dedicated page for each course.