/hyde/layouts/starter/layout/macros.j2
http://github.com/hyde/hyde · Jinja · 45 lines · 30 code · 5 blank · 10 comment · 9 complexity · 71fe974e989f19972880be22ade96803 MD5 · raw file
- {# Generates the main and basic menu from context data in the site's
- configuration file.
- #}
- {% macro render_basic_menu() -%}
- <ul class="basic">
- {% for menu_item in menu %}
- <li><a {% if (menu_item.url == resource.relative_path) %}class="selected" {% endif -%}
- href="{{ content_url(menu_item.url) }}">{{ menu_item.title }}</a></li>
- {% endfor %}
- </ul>
- {%- endmacro %}
- {# Generates the advanced menu from all files located in the content/advanced
- folder. Only advanced section files have 'index' metadata, so we can be
- certain that no other files will creep in.
- #}
- {% macro render_advanced_menu() -%}
- <ul class="advanced">
- {% for res in site.content.walk_resources_sorted_by_index() %}
- <li><a {% if (res.url == resource.url) %}class="selected" {% endif -%}
- href="{{ res.full_url }}">{{ res.meta.title }}</a></li>
- {% endfor %}
- </ul>
- {%- endmacro %}
- {# Advanced topics macro. Renders navigation at the end of an advanced
- article. It also depends on 'index' metadata.
- #}
- {% macro render_bottom_article_nav() %}
- <div class="bottom_article_nav">
- {% if resource.next_by_index is not none -%}
- <div class="next"><a href="{{ resource.next_by_index.full_url }}">
- {{ resource.next_by_index.meta.title }}</a>
- ></div>
- {%- endif %}
- {% if resource.prev_by_index is not none -%}
- <div class="prev">< <a href="{{ resource.prev_by_index.full_url }}">
- {{ resource.prev_by_index.meta.title }}</a>
- </div>
- {%- endif %}
- </div>
- {% endmacro %}