chiark / gitweb /
theme: highlight navbar items based on slug, not title.
authorVladimír Vondruš <mosra@centrum.cz>
Tue, 19 Sep 2017 19:26:56 +0000 (21:26 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 11 Oct 2017 19:54:40 +0000 (21:54 +0200)
Because more than one subpage can (and usually does) have the same
title.

pelican-theme/templates/base.html
pelican-theme/templates/base_blog.html
pelican-theme/templates/page.html

index ac9db964be83f8fcbc5c8f4ad69638c47113bc46..a4302d45f26c6f7864a0eb517aff5cd59b4dbf42 100644 (file)
         <div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
           <div class="m-row">
             <ol class="m-col-t-6 m-col-m-none">
-              {% for title, link, sub in LINKS_NAVBAR1 %}
+              {% for title, link, slug, sub in LINKS_NAVBAR1 %}
               <li>
-                <a href="{{ link }}"{% if title == page_title %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+                <a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
                 {% if sub %}
                 <ol>
-                  {% for title, link in sub %}
-                  <li><a href="{{ link }}">{{ title }}</a></li>
+                  {% for title, link, slug in sub %}
+                  <li><a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                   {% endfor %}
                 </ol>
                 {% endif %}
               {% endfor %}
             </ol>
             <ol class="m-col-t-6 m-col-m-none">
-              {% for title, link, sub in LINKS_NAVBAR2 %}
+              {% for title, link, slug, sub in LINKS_NAVBAR2 %}
               <li>
-                <a href="{{ link }}"{% if title == page_title %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+                <a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
                 {% if sub %}
                 <ol>
-                  {% for title, link in sub %}
-                  <li><a href="{{ link }}">{{ title }}</a></li>
+                  {% for title, link, slug in sub %}
+                  <li><a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                   {% endfor %}
                 </ol>
                 {% endif %}
index b0500088bf8aa6b353f75b97cdc03631e7c77425..597c88d4b761db3b5e734d37926d1dbba7c3853b 100644 (file)
@@ -1,4 +1,4 @@
-{% set page_title = 'Blog' %}
+{% set page_slug = 'blog' %}
 {% extends 'base.html' %}
 
 {% block title %}{{ BLOGNAME }}{% endblock %}
index 2032cc5e926e5639946843dcf70ee7158ccfeabb..8701037baae6e9be7b6aa1ab5e921c981e2d39ac 100644 (file)
@@ -1,4 +1,4 @@
-{% set page_title = page.title %}
+{% set page_slug = page.slug %}
 {% extends "base.html" %}
 
 {% block title %}