about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-05-29 16:01:03 +0200
committerAlan Pearce2024-05-29 16:01:03 +0200
commit99423f57f79499f13d021970c1efb4529072006b (patch)
treeaab3b0280ba6eabddb8ce8589538f9efb080a271
parentdea01a9d2d2853af740aff8d11f573a70e7c4962 (diff)
downloadzola-bearblog-99423f57f79499f13d021970c1efb4529072006b.tar.lz
zola-bearblog-99423f57f79499f13d021970c1efb4529072006b.tar.zst
zola-bearblog-99423f57f79499f13d021970c1efb4529072006b.zip
improve whitespace generation in output files
-rw-r--r--templates/base.html14
-rw-r--r--templates/header.html4
-rw-r--r--templates/language_switcher.html6
-rw-r--r--templates/macros.html14
-rw-r--r--templates/nav.html24
-rw-r--r--templates/page.html6
-rw-r--r--templates/section.html20
-rw-r--r--templates/taxonomy_list.html6
-rw-r--r--templates/taxonomy_single.html10
9 files changed, 51 insertions, 53 deletions
diff --git a/templates/base.html b/templates/base.html
index ee206b3..a2c5187 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -8,7 +8,7 @@
   <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 @@
   {%- 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>
diff --git a/templates/header.html b/templates/header.html
index 6e56025..54106ea 100644
--- a/templates/header.html
+++ b/templates/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>
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
index 512b409..04ce9a5 100644
--- a/templates/language_switcher.html
+++ b/templates/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 @@
       {%- endif %}
     {%- endfor %}
   </nav>
-{% endif %}
+{%- endif -%}
diff --git a/templates/macros.html b/templates/macros.html
index 2ad23e6..571c6e0 100644
--- a/templates/macros.html
+++ b/templates/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 %}
diff --git a/templates/nav.html b/templates/nav.html
index ba9f543..47a4254 100644
--- a/templates/nav.html
+++ b/templates/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 %}
diff --git a/templates/page.html b/templates/page.html
index cb33ab5..a51d965 100644
--- a/templates/page.html
+++ b/templates/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 @@
     {%- 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>
diff --git a/templates/section.html b/templates/section.html
index 9560719..a389c93 100644
--- a/templates/section.html
+++ b/templates/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 @@
       </small>
     {%- endif %}
     <ul class="blog-posts">
-      {% for page in section.pages %}
+      {%- for page in section.pages %}
         <li>
           <span>
             <i>
@@ -20,18 +20,16 @@
           </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>
diff --git a/templates/taxonomy_list.html b/templates/taxonomy_list.html
index 4b4e08a..f11519d 100644
--- a/templates/taxonomy_list.html
+++ b/templates/taxonomy_list.html
@@ -5,10 +5,10 @@
     <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>
diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html
index 9c9cebb..ea58c99 100644
--- a/templates/taxonomy_single.html
+++ b/templates/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 @@
       </small>
     {%- endif %}
     <ul class="blog-posts">
-      {% for page in term.pages %}
+      {%- for page in term.pages %}
         <li>
           <span>
             <i>
@@ -20,11 +20,11 @@
           </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 -%}