{###################################### menu widget Provide the widget with a content page that contains your menu: {{ widgets::menu(content="_common/menus/main.md") }} If the content page has a translation, it will be automatically loaded in the current language, as long as your parent template has a `lang` variable set, like so: {% set lang = section.lang | default(value=page.lang) %} Separate entries with a thematic break: either ---, ~~~, ___ or
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

tags in the menu. ######################################} {% macro menu(path) %}

{% endmacro menu %} {%- macro i18n_path(path) -%} {% if lang == config.default_language %}{{ path }} {%- else -%} {%- set parts = path | 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_path -%} {%- macro i18n_content(path) -%} {{ get_page(path=self::i18n_path(path=path)) | get(key="content") }} {%- endmacro i18n_content -%} {%- macro i18n_url(path) -%} {%- if lang == config.default_language -%}{{ get_url(path=path) }} {%- else -%} {%- set p = lang ~ "/" ~ path -%}{{ get_url(path=p) }}{%- endif -%} {%- endmacro i18n_url -%} {% macro translations(translations) %} ({{ lang }}) {% for t in translations %}{{ t.lang }}{% endfor %} {% endmacro translations %} {%- macro strip_lang_from_path(path, lang) -%} {%- set lang_path = lang ~ '/' -%} {%- if path is starting_with(lang_path) -%} {%- if path == lang_path -%} {%- set found_lang = true -%} {%- set path = "" -%} {%- else -%} {%- set path = path | replace(from=lang_path, to='') %} {%- endif -%} {%- endif -%} {% if path != '/' %}{{ path }}{% endif %} {%- endmacro strip_lang_from_path -%} {# Need to use separate names for variables, otherwise the paginator collides with that of index.html. Also, full_articles and section_title are useful to home section #} {% macro section(cur_section, cur_paginator=false, full_articles=true, title=true) %}
{% if title %}

{{ cur_section.title }}{% if cur_paginator and cur_paginator.number_pagers > 1 %} ({{ cur_paginator.current_index }}/{{ cur_paginator.number_pagers }}){% endif %}

{% endif %} {# Even if called from a different section (such as homepage), we want the semantic permalink to the collection to match the content #} {% set pages = cur_paginator.pages| default(value=cur_section.pages) %} {% for page in pages %}

{{ page.title }}

{%- if page.date -%}{%- endif -%}
{% if page.summary %}
{{ page.summary | markdown | safe }} --> {{ trans(key="readmore", lang=lang) }} <--
{% elif full_articles %}
{{ page.content | markdown | safe }}
{% endif %}
{% endfor %} {% if cur_paginator and cur_paginator.number_pagers > 1 %} {% endif %}
{% endmacro section %}