Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nav_order and Fix hardcoded navbar titles #664

Merged
merged 3 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ panelbear_analytics: # panelbear analytics site ID (format: XXXXXXXXX)
# 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
permalink: /blog/:year/:title/

Expand Down
22 changes: 14 additions & 8 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- Nav Bar -->
<nav id="navbar" class="navbar navbar-light navbar-expand-sm {% if site.navbar_fixed %}fixed-top{% else %}sticky-top{% endif %}">
<div class="container">
{% if page.title != "about" -%}
{% if page.permalink != '/' -%}
<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 -%}
</a>
Expand All @@ -25,27 +25,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 }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is flipping the order from {{ title }} | {{ page.title }} to {{ page.title }} | {{ title }} intentional? (I don't have a particular preference, just wondering if your decision was motivated by something.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was intentional, I was motivated by various websites (such as Gmail, Twitter, GitHub, Reddit, all these websites show page specific info before the website title).

Also, this make sense in a way that there is only a small amount of space to show information in the tabs, therefore it will be beneficial to show page specific info before the website title. Otherwise, the website title is the only thing that is visible throughout the website (since most of the other info get hidden because of tab size).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. thanks for researching this!

{%- 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
1 change: 1 addition & 0 deletions _pages/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: projects
permalink: /projects/
description: A growing collection of your cool projects.
nav: true
nav_order: 1
display_categories: [work, fun]
horizontal: false
---
Expand Down
1 change: 1 addition & 0 deletions _pages/publications.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: publications
description: publications by categories in reversed chronological order. generated by jekyll-scholar.
years: [1956, 1950, 1935, 1905]
nav: true
nav_order: 2
---
<!-- _pages/publications.md -->
<div class="publications">
Expand Down
1 change: 1 addition & 0 deletions _pages/teaching.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ permalink: /teaching/
title: teaching
description: Materials for courses you taught. Replace this text with your description.
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.
Expand Down