Add navigation data file to simplify link output/ordering

This commit is contained in:
Kyle Gordy 2019-11-22 19:52:33 -05:00
parent 54771fd0a8
commit dec03c6eee
3 changed files with 50 additions and 50 deletions

8
_data/navigation.yml Normal file
View File

@ -0,0 +1,8 @@
- title: Blog
url: "/blog/"
- title: Projects
url: "/projects/"
- title: Careers
url: "/careers/"

View File

@ -7,23 +7,19 @@
{% include logo.html color="dark" %}
</a>
<!-- Page list -->
{%- if page_paths -%}
<!-- Site links -->
{% assign links = site.data.navigation %}
<ul class="footer-nav list--plain monospace">
{%- for path in page_paths -%}
{%- assign my_page = site.pages | where: "path", path | first -%}
{% for link in links %}
{% assign class = nil %}
{% if page.url == my_page.url %}
{% if page.url contains link.url or page.url contains link.title %}
{% assign class = 'active' %}
{% endif %}
{%- if my_page.title -%}
<li class="footer-nav__item">
<a class="footer-link {{ class }}" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a>
<a class="footer-link {{ class }}" href="{{ site.baseurl }}{{ link.url }}">{{ link.title }}</a>
</li>
{%- endif -%}
{%- endfor -%}
{% endfor %}
</ul>
{%- endif -%}
<!-- Social icons-->
<ul class="footer-social-list list--inline">

View File

@ -21,21 +21,18 @@
</span>
</button>
<!-- Page list -->
{%- if page_paths -%}
<!-- Site links -->
{% assign links = site.data.navigation %}
<ul class="nav-list list--plain monospace">
{%- for path in page_paths -%}
{%- assign my_page = site.pages | where: "path", path | first -%}
{% for link in links %}
{% assign class = nil %}
{% if page.url == my_page.url %}
{% if page.url contains link.url or page.url contains link.title %}
{% assign class = 'active' %}
{% endif %}
{%- if my_page.title -%}
<li class="nav-list__item">
<a class="nav-list__link {{ class }}" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a>
<a class="nav-list__link {{ class }}" href="{{ site.baseurl }}{{ link.url }}">{{ link.title }}</a>
</li>
{%- endif -%}
{%- endfor -%}
{% endfor %}
<!-- Social icons (mobile only) -->
<li class="nav-social-list hidden-md">
@ -62,6 +59,5 @@
<a class="nav-github-link text-white" href="{{site.github.repository_url}}/edit/{{ site.branch }}/{{page.path}}">Improve this Page</a><a class="nav-github-link text-white" href="{{site.github.repository_url}}/commits/{{ site.branch }}/{{page.path}}">Page History</a>
</li>
</ul>
{%- endif -%}
</nav>
</header>