/hyde/layouts/starter/layout/macros.j2
Jinja | 45 lines | 30 code | 5 blank | 10 comment | 9 complexity | 71fe974e989f19972880be22ade96803 MD5 | raw file
1{# Generates the main and basic menu from context data in the site's 2 configuration file. 3#} 4{% macro render_basic_menu() -%} 5<ul class="basic"> 6{% for menu_item in menu %} 7 <li><a {% if (menu_item.url == resource.relative_path) %}class="selected" {% endif -%} 8 href="{{ content_url(menu_item.url) }}">{{ menu_item.title }}</a></li> 9{% endfor %} 10</ul> 11{%- endmacro %} 12 13 14{# Generates the advanced menu from all files located in the content/advanced 15 folder. Only advanced section files have 'index' metadata, so we can be 16 certain that no other files will creep in. 17#} 18{% macro render_advanced_menu() -%} 19<ul class="advanced"> 20{% for res in site.content.walk_resources_sorted_by_index() %} 21 <li><a {% if (res.url == resource.url) %}class="selected" {% endif -%} 22 href="{{ res.full_url }}">{{ res.meta.title }}</a></li> 23{% endfor %} 24</ul> 25{%- endmacro %} 26 27 28{# Advanced topics macro. Renders navigation at the end of an advanced 29 article. It also depends on 'index' metadata. 30#} 31{% macro render_bottom_article_nav() %} 32<div class="bottom_article_nav"> 33{% if resource.next_by_index is not none -%} 34 <div class="next"><a href="{{ resource.next_by_index.full_url }}"> 35 {{ resource.next_by_index.meta.title }}</a> 36 ></div> 37{%- endif %} 38 39{% if resource.prev_by_index is not none -%} 40 <div class="prev">< <a href="{{ resource.prev_by_index.full_url }}"> 41 {{ resource.prev_by_index.meta.title }}</a> 42 </div> 43{%- endif %} 44</div> 45{% endmacro %}