misc:zola_tips
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
misc:zola_tips [2022/12/25 00:23] – [Custom frontmatter variables] mithat | misc:zola_tips [2022/12/25 22:23] – [Breadcrumbs] mithat | ||
---|---|---|---|
Line 16: | Line 16: | ||
<WRAP center info 80%> | <WRAP center info 80%> | ||
- | This whole setup seems like it's more complicated than it needs to be. | + | This scheme |
</ | </ | ||
Line 23: | Line 23: | ||
'' | '' | ||
- | If you don't have a '' | + | You don' |
You can nest sections. | You can nest sections. | ||
Line 48: | Line 48: | ||
{% endif %} | {% endif %} | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | **Better yet**, use the following idiom to set '' | ||
+ | |||
+ | <code twig> | ||
+ | {% set current = section | default(value=page) %} | ||
+ | {{ current.title }} | ||
</ | </ | ||
Line 111: | Line 118: | ||
===== Marking a menu item as active ===== | ===== Marking a menu item as active ===== | ||
+ | There may be a better way to do this, but selectively adding a class if the relative path matches seems to work. | ||
+ | <code twig> | ||
+ | <ul class=" | ||
+ | {# for each of the menu entries, if the relative path leads matches the page, add class=" | ||
+ | {% set current = section | default(value=page) %} | ||
+ | {% set rpath = current.relative_path %} | ||
+ | <li {% if rpath == " | ||
+ | <li class=" | ||
+ | <a href="#" | ||
+ | <ul class=" | ||
+ | <li {% if rpath == " | ||
+ | <li {% if rpath == " | ||
+ | <li {% if rpath == " | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li {% if rpath == " | ||
+ | <li {% if rpath == " | ||
+ | </ul> | ||
+ | </ | ||
+ | No doubt, there are opportunities to stuff some of this into macros and/or partials and/or similar. | ||
===== Breadcrumbs ===== | ===== Breadcrumbs ===== | ||
+ | See this [[https:// | ||
+ | <code twig> | ||
+ | {% block breadcrumb %} | ||
+ | <div class=" | ||
+ | <a class=" | ||
+ | {% set current = section | default(value=page) %} | ||
+ | {% for ancestor in current.ancestors %} | ||
+ | {% if loop.first %} | ||
+ | {% continue %} | ||
+ | {% endif %} | ||
+ | <span class=" | ||
+ | {% set section = get_section(path=ancestor) %} | ||
+ | <a class=" | ||
+ | {% endfor %} | ||
+ | <span class=" | ||
+ | <a class=" | ||
+ | </ | ||
+ | {% endblock breadcrumb %} | ||
+ | </ |
misc/zola_tips.txt · Last modified: 2022/12/25 22:57 by mithat