chiark / gitweb /
theme: ability to override which menu item is highlighted.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 2 Nov 2017 19:23:32 +0000 (20:23 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 2 Nov 2017 19:52:51 +0000 (20:52 +0100)
doc/pelican/theme-test.rst
doc/pelican/theme.rst
pelican-theme/templates/base.html

index f00a82b736089a85cbf5973ef0acf8f50f3ec68d..7a887819930531b1534f6920fec74a3a1895f33e 100644 (file)
@@ -31,6 +31,7 @@ Test
 :css: {filename}/static/dummy.css
       {filename}/static/dummy.css
 :summary: um
+:highlight: pelican/theme
 :header:
     .. note-warning::
 
@@ -43,4 +44,5 @@ Test
         This shouldn't be wrapped in a ``<p>``.
 
 This page should have a breadcrumb, summary in a meta tag, header and a footer
-and also two additional links to ``/static/dummy.css``.
+and also two additional links to ``/static/dummy.css``. It should also
+highlight the Pelican Theme menu item in the top navbar.
index aeb9c967260664f90d0f22e18ca10e26cc832826..6f08f2764d0bf711e855563f7b4c2cfc86f7f805 100644 (file)
@@ -205,6 +205,10 @@ elsewhere; the container is marked as `inflatable <{filename}/css/grid.rst#infla
 Page title is rendered in an :html:`<h1>` and there's nothing else apart from
 the page content.
 
+Pages can override which menu item in the `top navbar`_ will be highlighted
+by specifying the corresponding menu item slug in the :rst:`:highlight:` field.
+If the field is not present, page's own slug is used instead.
+
 `Extra CSS`_
 ------------
 
index 52a421d1f970bf1783cba92f4927ff8130b2231d..11ecef6811cbccabe93fe75355f61efa1c7068a9 100644 (file)
           <ol class="m-col-t-6 m-col-m-none">
             {% for title, link, slug, sub in LINKS_NAVBAR1 %}
             <li>
-              <a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+              <a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
               {% if sub %}
               <ol>
                 {% for title, link, slug in sub %}
-                <li><a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
+                <li><a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                 {% endfor %}
               </ol>
               {% endif %}
           <ol class="m-col-t-6 m-col-m-none">
             {% for title, link, slug, sub in LINKS_NAVBAR2 %}
             <li>
-              <a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
+              <a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a>
               {% if sub %}
               <ol>
                 {% for title, link, slug in sub %}
-                <li><a href="{{ link }}"{% if slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
+                <li><a href="{{ link }}"{% if (page and page.highlight == slug) or slug == page_slug %} id="m-navbar-current"{% endif %}>{{ title }}</a></li>
                 {% endfor %}
               </ol>
               {% endif %}