diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-04-10 13:03:02 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-04-10 13:03:02 +0300 |
commit | 8e11e56f51c425e3771c297cd44174afb2778281 (patch) | |
tree | 6228147204dc80e0ccba7805781bffdcedc3a853 | |
parent | bump Bootstrap to 3.4.1 (diff) | |
download | jekyll-theme-8e11e56f51c425e3771c297cd44174afb2778281.tar.gz jekyll-theme-8e11e56f51c425e3771c297cd44174afb2778281.zip |
navbar: rework front matter interface
Diffstat (limited to '')
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | _includes/common/navbar.html | 19 | ||||
-rw-r--r-- | archive/index.html | 5 | ||||
-rw-r--r-- | feed/index.html | 7 | ||||
-rw-r--r-- | index.md | 6 |
5 files changed, 28 insertions, 17 deletions
@@ -59,11 +59,13 @@ Features Hide the navbar by setting either `site.settings.navbar.hide` or `page.navbar.hide` to `true`. -Put a page on the navbar by defining setting `page.navbar_link` to `true` or +Put a page on the navbar by defining setting `page.navbar.link` to `true` or a custom HTML string. -Pages are sorted in the ascending order of `page.navbar_priority`. -If a page on the navbar is paginated, set `page.navbar_paginated` to `true` so +Pages are sorted in the ascending order of `page.navbar.priority`. +If a page on the navbar is paginated, set `page.navbar.paginated` to `true` so that it doesn't appear two or more times. +You can add a glyphicon to the navbar link by settings `page.navbar.icon` to +something like `home`, `envelope`, etc. ### Post feed diff --git a/_includes/common/navbar.html b/_includes/common/navbar.html index 9f01639..7e5fa4e 100644 --- a/_includes/common/navbar.html +++ b/_includes/common/navbar.html @@ -11,32 +11,37 @@ </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> - {% assign page_list = site.pages | where_exp: "x","x.navbar_link" | sort: "navbar_priority" %} + {% assign page_list = site.pages | where_exp: "x","x.navbar.link" | sort: "navbar.priority" %} {% for node in page_list %} {% comment %} Whether a page should be present in the navbar is determined by - the presense of navbar_link in the page's front matter. It can be + the presense of navbar.link in the page's front matter. It can be true, in which case page's title is used, or it can be custom HTML. If the page is paginated, it should be marked as such by setting - navbar_paginated to true in its front matter. That way, /pageN/ + navbar.paginated to true in its front matter. That way, /pageN/ pages, which would have the same navbar_link, wouldn't appear in the navbar. {% endcomment %} - {% if node.navbar_paginated %} + {% if node.navbar.paginated %} {% if navbar_has_paginated %} {% continue %} {% endif %} {% assign navbar_has_paginated = true %} {% endif %} - {% assign link = node.navbar_link %} + {% assign link = node.navbar.link %} {% if link == true %} {% assign link = node.title %} {% endif %} + {% capture link %}{{ link | upcase }}{% endcapture %} + {% assign icon = node.navbar.icon %} + {% if icon %} + {% capture icon %}<span class="glyphicon glyphicon-{{ icon }}"></span> {% endcapture %} + {% endif %} {% if page.url == node.url %} - <li class="active"><a href="{{ node.url | relative_url }}" class="active">{{ link }}</a></li> + <li class="active"><a href="{{ node.url | relative_url }}" class="active">{{ icon }}{{ link }}</a></li> {% else %} - <li><a href="{{ node.url | relative_url }}">{{ link }}</a></li> + <li><a href="{{ node.url | relative_url }}">{{ icon }}{{ link }}</a></li> {% endif %} {% endfor %} </ul> diff --git a/archive/index.html b/archive/index.html index a91f16d..eec97db 100644 --- a/archive/index.html +++ b/archive/index.html @@ -1,7 +1,8 @@ --- title: Archive layout: default -navbar_link: true -navbar_priority: 3 +navbar: + link: true + priority: 3 --- {% include categories/categories.html %} diff --git a/feed/index.html b/feed/index.html index 0bcee1f..42a5d53 100644 --- a/feed/index.html +++ b/feed/index.html @@ -1,8 +1,9 @@ --- title: Feed layout: default -navbar_link: true -navbar_priority: 2 -navbar_paginated: true +navbar: + link: true + priority: 2 + paginated: true --- {% include posts/posts.html %} @@ -1,7 +1,9 @@ --- title: Home page -navbar_link: <span class="glyphicon glyphicon-home"></span> Home -navbar_priority: 1 +navbar: + link: Home + icon: home + priority: 1 --- This is a theme preview. Check out these: |