all repos — zola-bearblog @ 99423f57f79499f13d021970c1efb4529072006b

Port of bear blog theme to zola

improve whitespace generation in output files

Alan Pearce
commit

99423f57f79499f13d021970c1efb4529072006b

parent

dea01a9d2d2853af740aff8d11f573a70e7c4962

M templates/base.htmltemplates/base.html
@@ -8,7 +8,7 @@ <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> {% include "favicon.html" ignore missing -%} <title>{%- block title %}{{ config.title }}{%- endblock %}</title> - {% include "seo_tags.html" ignore missing %} + {% include "seo_tags.html" ignore missing -%} <meta name="referrer" content="no-referrer-when-downgrade"> {%- if config.generate_feed %} {% block rss -%}
@@ -16,14 +16,14 @@ <link rel="alternate" type={% if config.feed_filename == "atom.xml" %}"application/atom+xml"{% else %}"application/rss+xml"{% endif %} title="{{ config.title }}" href="{{ get_url(path=config.feed_filename) | safe }}">
{%- endblock -%} {%- endif %} <style> - {%- include "style.css.html" ignore missing -%} + {% include "style.css.html" ignore missing %} </style> - {% include "custom_head.html" ignore missing -%} + {%- include "custom_head.html" ignore missing %} </head> <body> - {% include "header.html" ignore missing -%} - {% block main %}{%- endblock -%} - {% include "footer.html" ignore missing -%} - {% include "custom_body.html" ignore missing -%} + {% include "header.html" ignore missing %} + {%- block main -%}{%- endblock -%} + {%- include "footer.html" ignore missing -%} + {%- include "custom_body.html" ignore missing -%} </body> </html>
M templates/header.htmltemplates/header.html
@@ -1,9 +1,9 @@
<header> - {% include "language_switcher.html" %} + {%- include "language_switcher.html" %} <a href="{{ get_url(path="@/_index.md", lang=lang) }}" class="title"> <h1>{{ config.title }}</h1> </a> <nav> - {% include "nav.html" %} + {%- include "nav.html" %} </nav> </header>
M templates/language_switcher.htmltemplates/language_switcher.html
@@ -1,6 +1,6 @@
-{% if config.extra.language_switcher %} +{%- if config.extra.language_switcher %} <nav class="lang"> - {%- set language_agnostic_path = current_path | default(value="/") | replace(from='/' ~ lang ~ '/', to = '/') | trim_start_matches(pat = '/') -%} + {%- set language_agnostic_path = current_path | default(value="/") | replace(from='/' ~ lang ~ '/', to = '/') | trim_start_matches(pat = '/') %} {%- for tr in config.extra.translations %} {%- if tr.code == lang %} <active>{{ tr.name }}</active>
@@ -9,4 +9,4 @@ <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}">{{ tr.name }}</a>
{%- endif %} {%- endfor %} </nav> -{% endif %} +{%- endif -%}
M templates/macros.htmltemplates/macros.html
@@ -1,12 +1,12 @@
-{% macro table_of_contents(toc, max_level) %} +{%- macro table_of_contents(toc, max_level) %} <ul> - {% for header in toc %} + {%- for header in toc %} <li> <a href="{{ header.permalink | safe }}">{{ header.title }}</a> - {% if header.children and header.level < max_level %} - {{ self::table_of_contents(toc=header.children, max_level=max_level) }} - {% endif %} + {%- if header.children and header.level < max_level %} + {{- self::table_of_contents(toc=header.children, max_level=max_level) | indent() | safe() }} + {%- endif %} </li> - {% endfor %} + {%- endfor %} </ul> -{% endmacro %} +{%- endmacro %}
M templates/nav.htmltemplates/nav.html
@@ -1,17 +1,17 @@
-{% set current_lang = config.default_language %} -{% if page %} - {% set current_lang = page.lang %} -{% elif section %} - {% set current_lang = section.lang %} -{% endif %} +{%- set current_lang = config.default_language %} +{%- if page %} + {%- set current_lang = page.lang %} +{%- elif section %} + {%- set current_lang = section.lang %} +{%- endif %} {%- if config.extra.main_menu %} {%- for item in config.extra.main_menu %} - {% if current_lang == config.default_language %} - {% set title = item.name %} - {% else %} - {% set language_key = 'name_' ~ current_lang %} - {% set title = item[language_key] %} - {% endif %} + {%- if current_lang == config.default_language %} + {%- set title = item.name %} + {%- else %} + {%- set language_key = 'name_' ~ current_lang %} + {%- set title = item[language_key] %} + {%- endif %} {%- if item.url is matching("https?://") %} <a href="{{ item.url }}">{{ title }}</a> {%- else %}
M templates/page.htmltemplates/page.html
@@ -4,7 +4,7 @@
{% block title %}{{ page.title }} | {{ super() }}{% endblock %} {% block main %} - {%- if not page.extra.menu %} + {%- if not page.extra.menu -%} <h1>{{ page.title }}</h1> {%- if page.date %} <p>
@@ -17,9 +17,9 @@ </p>
{%- endif %} {%- endif %} {%- if config.extra.table_of_contents.show and not page.extra.hide_table_of_contents and page.toc %} - <details {%if config.extra.table_of_contents.visible_on_load %}open{% endif %}> + <details {% if config.extra.table_of_contents.visible_on_load %}open{% endif %}> <summary>{{ trans(key="table_of_contents", lang=lang) }}</summary> - {{ macros::table_of_contents(toc=page.toc, max_level=config.extra.table_of_contents.max_level) }} + {{- macros::table_of_contents(toc=page.toc, max_level=config.extra.table_of_contents.max_level) | indent() | safe() }} </details> {%- endif %} <main>
M templates/section.htmltemplates/section.html
@@ -1,6 +1,6 @@
{% extends "base.html" %} -{% block main %} +{%- block main -%} <main> {%- if taxonomy.term %} <h3 class="filter">{{ trans(key="filtering_for",lang=lang)}} "{{ section.title }}"</h3>
@@ -9,7 +9,7 @@ <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">{{ trans(key="remove_filter", lang=lang) }}</a>
</small> {%- endif %} <ul class="blog-posts"> - {% for page in section.pages %} + {%- for page in section.pages %} <li> <span> <i>
@@ -20,18 +20,16 @@ </i>
</span> <a href="{{ page.permalink }}">{{ page.title }}</a> </li> - {% else %} - <li> - {{ trans(key="no_posts", lang=lang) }} - </li> - {% endfor %} + {%- else %} + <li>{{ trans(key="no_posts", lang=lang) }}</li> + {%- endfor -%} </ul> <small> <div> - {% set tags = get_taxonomy(kind="tags", lang=lang) %} - {% for post in tags.items %} - <a href="{{ post.permalink }}">#{{ post.name }}</a>&nbsp; - {% endfor %} + {%- set tags = get_taxonomy(kind="tags", lang=lang) %} + {%- for post in tags.items %} + <a href="{{ post.permalink }}">#{{ post.name }}</a>&nbsp; + {%- endfor %} </div> </small> </main>
M templates/taxonomy_list.htmltemplates/taxonomy_list.html
@@ -5,10 +5,10 @@ <main>
<h1>{{ taxonomy.name | capitalize }}</h1> <small> <div> - {% set tags = get_taxonomy(kind="tags", lang=lang) %} - {% for post in tags.items %} + {%- set tags = get_taxonomy(kind="tags", lang=lang) %} + {%- for post in tags.items %} <a href="{{ post.permalink }}">#{{ post.name }}</a>&nbsp; - {% endfor %} + {%- endfor %} </div> </small> </main>
M templates/taxonomy_single.htmltemplates/taxonomy_single.html
@@ -1,6 +1,6 @@
{% extends "base.html" %} -{% block main %} +{%- block main -%} <main> {%- if term %} <h3 class="filter">Filtering for "{{ term.name }}"</h3>
@@ -9,7 +9,7 @@ <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">{{ trans(key="remove_filter", lang=lang) }}</a>
</small> {%- endif %} <ul class="blog-posts"> - {% for page in term.pages %} + {%- for page in term.pages %} <li> <span> <i>
@@ -20,11 +20,11 @@ </i>
</span> <a href="{{ page.permalink }}">{{ page.title }}</a> </li> - {% else %} + {%- else %} <li> {{ trans(key="no_posts", lang=lang) }} </li> - {% endfor %} + {%- endfor %} </ul> </main> -{% endblock %} +{%- endblock -%}