2020-03-29 17:26:12 +02:00
{######################################
menu widget
Provide the widget with a content page
that contains your menu:
{{ widgets::menu(content="_common/menus/main.md") }}
Separate entries with a thematic break:
either ---, ~~~, ___ or < hr / >
An entry can be either text, a link, or
a submenu. A submenu is an actual list
defined using Markdown or HTML.
You cannot use < p > tags in the menu.
######################################}
{% macro menu(content) %}
< nav class = "nav-menu" role = "navigation" >
2020-03-30 01:14:14 +02:00
{%- set source = get_page(path=self::i18n_page(page=content)) %}{% set entries = source.content | split(pat="< hr / > ") %}{# fetch page content and divide it with separator -#}
2020-03-29 17:26:12 +02:00
{%- for entry in entries %}
{{ entry | trim | replace(from="< p > ", to="") | replace(from="< / p > ", to="") | safe }}{# strip paragraph tags away for nicer markup #}
{%- endfor %}
< / nav >
{% endmacro menu %}
2020-03-30 01:14:14 +02:00
{%- macro i18n(key) -%}
{{ trans(key=key, lang=lang) }}
{%- endmacro i18n -%}
{%- macro i18n_page(page) -%}
{% if lang == "en" %}{{ page }}
{%- else -%}
{%- set parts = page | split(pat=".md") -%}
{%- for part in parts -%}
{%- if part and not loop.first -%}.md{%- endif -%}
{%- if not loop.last -%}{{ part }}{%- endif -%}
{%- endfor -%}
.{{ lang }}.md
{%- endif -%}
{%- endmacro i18n_page -%}