From 678aecdd6161e80495eb8398247c0f8423f71cf1 Mon Sep 17 00:00:00 2001 From: Michael Rose <est.michael@gmail.com> Date: Fri, 25 Mar 2016 14:12:03 -0400 Subject: [PATCH] Build navigation list include helper - Update navigation.yml to support multiple navigations and levels - Optional include navigation into left sidebar --- _data/docs.yml | 56 +++++++++++++++++++++++++++ _data/navigation.yml | 86 ++++++++++++++++++++++++++++++++++------- _includes/masthead.html | 2 +- _includes/nav_list.html | 24 ++++++++++++ _includes/sidebar.html | 3 ++ 5 files changed, 157 insertions(+), 14 deletions(-) create mode 100644 _data/docs.yml create mode 100644 _includes/nav_list.html diff --git a/_data/docs.yml b/_data/docs.yml new file mode 100644 index 00000000..0727e436 --- /dev/null +++ b/_data/docs.yml @@ -0,0 +1,56 @@ +- title: Getting Started + children: + - title: "Quick Start Guide" + path: quick-start-guide + - title: "Installation" + path: installation + - title: "Upgrading" + path: upgrading + - title: "Structure" + path: structure + +- title: Customization + children: + - title: "Configuration" + path: configuration + - title: "Navigation" + path: navigation + - title: "Authors" + path: authors + - title: "UI Text" + path: ui-text + - title: "Layouts" + path: layouts + +- title: Content + children: + - title: "Working with Posts" + path: working-with-posts + - title: "Working with Pages" + path: working-with-pages + - title: "Working with Collections" + path: working-with-collections + - title: "Jekyll Include Helpers" + path: include-helpers + - title: "Images" + path: images + +- title: Miscellaneous + children: + - title: "Pagination" + path: pagination + - title: "Archives" + path: archives + - title: "Development" + path: development + - title: "v2 Documentation" + path: docs-2 + +- title: Meta + children: + - title: "Contributing" + path: contributing + - title: "License" + path: license + - title: "History" + path: history \ No newline at end of file diff --git a/_data/navigation.yml b/_data/navigation.yml index 2514253b..8a6397bb 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -1,19 +1,79 @@ -# Site navigation links +# main links links +main: + - title: "Theme Setup" + url: /theme-setup/ -- title: "Theme Setup" - url: /theme-setup/ + - title: "Posts" + url: /year-archive/ -- title: "Posts" - url: /year-archive/ + - title: "Categories" + url: /categories/ -- title: "Categories" - url: /categories/ + - title: "Tags" + url: /tags/ -- title: "Tags" - url: /tags/ + - title: "Pages" + url: /page-archive/ -- title: "Pages" - url: /page-archive/ + - title: "Collections" + url: /collection-archive/ -- title: "Collections" - url: /collection-archive/ \ No newline at end of file + +# documentation links +docs: + - title: Getting Started + children: + - title: "Quick Start Guide" + path: quick-start-guide + - title: "Installation" + path: installation + - title: "Upgrading" + path: upgrading + - title: "Structure" + path: structure + + - title: Customization + children: + - title: "Configuration" + path: configuration + - title: "Navigation" + path: navigation + - title: "Authors" + path: authors + - title: "UI Text" + path: ui-text + - title: "Layouts" + path: layouts + + - title: Content + children: + - title: "Working with Posts" + path: working-with-posts + - title: "Working with Pages" + path: working-with-pages + - title: "Working with Collections" + path: working-with-collections + - title: "Jekyll Include Helpers" + path: include-helpers + - title: "Images" + path: images + + - title: Miscellaneous + children: + - title: "Pagination" + path: pagination + - title: "Archives" + path: archives + - title: "Development" + path: development + - title: "v2 Documentation" + path: docs-2 + + - title: Meta + children: + - title: "Contributing" + path: contributing + - title: "License" + path: license + - title: "History" + path: history \ No newline at end of file diff --git a/_includes/masthead.html b/_includes/masthead.html index b851bdb4..a96b132c 100644 --- a/_includes/masthead.html +++ b/_includes/masthead.html @@ -7,7 +7,7 @@ <nav id="site-nav" class="greedy-nav"> <button><div class="navicon"></div></button> <ul class="visible-links"> - {% for link in site.data.navigation %} + {% for link in site.data.navigation.main %} {% if link.url contains 'http' %} {% assign domain = '' %} {% else %} diff --git a/_includes/nav_list.html b/_includes/nav_list.html new file mode 100644 index 00000000..f39e389c --- /dev/null +++ b/_includes/nav_list.html @@ -0,0 +1,24 @@ +{% include base_path %} +{% assign navigation = site.data.navigation[page.sidebar.nav] %} + +<nav> + <ul> + {% for nav in navigation %} + <li>{{ nav.title }} + {% if nav.children != null %} + <ul> + {% for child in nav.children %} + {% assign nav_url = child.path | prepend: "/" | prepend: page.sidebar.nav | prepend: "/" | append: "/" | prepend: base_path %} + {% if nav_url contains page.url %} + {% assign c = "current" %} + {% else %} + {% assign c = "" %} + {% endif %} + <li><a href="{{ nav_url }}" class="{{ c }}">{{ child.title }}</a></li> + {% endfor %} + </ul> + {% endif %} + </li> + {% endfor %} + </ul> +</nav> \ No newline at end of file diff --git a/_includes/sidebar.html b/_includes/sidebar.html index c447a69d..9949c74d 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -15,6 +15,9 @@ {% if s.title %}<h3>{{ s.title }}</h3>{% endif %} {% if s.text %}{{ s.text | markdownify }}{% endif %} {% endfor %} + {% if page.sidebar.nav %} + {% include nav_list.html items=page.sidebar.nav %} + {% endif %} {% endif %} </div> {% endif %} \ No newline at end of file