about summary refs log tree commit diff stats
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/base.html7
-rw-r--r--templates/footer.html2
-rw-r--r--templates/header.html5
-rw-r--r--templates/language_switcher.html12
-rw-r--r--templates/macros.html12
-rw-r--r--templates/nav.html17
-rw-r--r--templates/page.html9
-rw-r--r--templates/section.html8
-rw-r--r--templates/security_tags.html2
-rw-r--r--templates/seo_tags.html1
-rw-r--r--templates/style.css.html (renamed from templates/style.html)16
-rw-r--r--templates/taxonomy_list.html3
-rw-r--r--templates/taxonomy_single.html8
13 files changed, 82 insertions, 20 deletions
diff --git a/templates/base.html b/templates/base.html
index 4ba8442..ee206b3 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -1,6 +1,9 @@
 <!DOCTYPE html>
 <html lang="{{ lang | default(value="en-US" ) }}">
 <head>
+  {%- if config.webserver_sends_csp_headers %}
+  {%- include "security_tags.html" ignore missing %}
+  {%- endif %}
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   {% include "favicon.html" ignore missing -%}
@@ -12,7 +15,9 @@
   <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 %}
-  {% include "style.html" ignore missing -%}
+  <style>
+  {%- include "style.css.html" ignore missing -%}
+  </style>
   {% include "custom_head.html" ignore missing -%}
 </head>
 <body>
diff --git a/templates/footer.html b/templates/footer.html
index c952a93..6d4f0f7 100644
--- a/templates/footer.html
+++ b/templates/footer.html
@@ -1,5 +1,5 @@
 <footer>
   {%- if not config.extra.hide_made_with_line %}
-    Made with <a href="https://codeberg.org/alanpearce/zola-bearblog">Zola ʕ•ᴥ•ʔ Bear</a>
+    {{ trans(key="made_with", lang=lang) }} <a href="https://codeberg.org/alanpearce/zola-bearblog">Zola ʕ•ᴥ•ʔ Bear</a>
   {%- endif %}
 </footer>
diff --git a/templates/header.html b/templates/header.html
index c1d3c3e..6e56025 100644
--- a/templates/header.html
+++ b/templates/header.html
@@ -1,6 +1,7 @@
 <header>
-  <a href="{{ config.base_url }}" class="title">
-    <h2>{{ config.title }}</h2>
+  {% include "language_switcher.html" %}
+  <a href="{{ get_url(path="@/_index.md", lang=lang) }}" class="title">
+    <h1>{{ config.title }}</h1>
   </a>
   <nav>
     {% include "nav.html" %}
diff --git a/templates/language_switcher.html b/templates/language_switcher.html
new file mode 100644
index 0000000..512b409
--- /dev/null
+++ b/templates/language_switcher.html
@@ -0,0 +1,12 @@
+{% if config.extra.language_switcher %}
+  <nav class="lang">
+    {%- 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>
+      {%- else %}
+          <a href="{{ get_url(path=language_agnostic_path, lang=tr.code) ~ "/" }}" hreflang="{{ tr.code }}">{{ tr.name }}</a>
+      {%- endif %}
+    {%- endfor %}
+  </nav>
+{% endif %}
diff --git a/templates/macros.html b/templates/macros.html
new file mode 100644
index 0000000..2ad23e6
--- /dev/null
+++ b/templates/macros.html
@@ -0,0 +1,12 @@
+{% macro table_of_contents(toc, max_level) %}
+<ul>
+  {% 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 %}
+    </li>
+  {% endfor %}
+</ul>
+{% endmacro %}
diff --git a/templates/nav.html b/templates/nav.html
index e006ab1..ba9f543 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -1,10 +1,21 @@
-<a href="{{ config.base_url }}">Home</a>
+{% 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 item.url is matching("https?://") %}
-      <a href="{{ item.url }}">{{ item.name }}</a>
+      <a href="{{ item.url }}">{{ title }}</a>
     {%- else %}
-      <a href="{{ get_url(path=item.url )}}">{{ item.name }}</a>
+      <a href="{{ get_url(path=item.url, lang=lang )}}">{{ title }}</a>
     {%- endif %}
   {%- endfor %}
 {%- endif -%}
diff --git a/templates/page.html b/templates/page.html
index 89de955..2e2ef86 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -1,3 +1,4 @@
+{% import "macros.html" as macros %}
 {% extends "base.html" %}
 
 {% block title %}{{ page.title }} | {{ super() }}{% endblock %}
@@ -15,6 +16,12 @@
       </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 %}>
+      <summary>Table of Contents</summary>
+      {{ macros::table_of_contents(toc=page.toc, max_level=config.extra.table_of_contents.max_level) }}
+    </details>
+  {%- endif %}
   <main>
     {{ page.content | safe }}
   </main>
@@ -23,7 +30,7 @@
       {%- for name, taxon in page.taxonomies %}
         {{ name | capitalize }}:
         {%- for item in taxon %}
-          <a href="{{ get_taxonomy_url(kind=name, name=item) }}">#{{ item }}</a>
+          <a href="{{ get_taxonomy_url(kind=name, name=item, lang=lang) }}">#{{ item }}</a>
         {%- endfor %}
       {%- endfor %}
     {%- endif %}
diff --git a/templates/section.html b/templates/section.html
index e596ffb..9560719 100644
--- a/templates/section.html
+++ b/templates/section.html
@@ -3,9 +3,9 @@
 {% block main %}
   <main>
     {%- if taxonomy.term %}
-      <h3 style="margin-bottom:0">Filtering for "{{ section.title }}"</h3>
+      <h3 class="filter">{{ trans(key="filtering_for",lang=lang)}} "{{ section.title }}"</h3>
       <small>
-        <a href="{{ get_url(path="@/blog/_index.md") }}">Remove filter</a>
+        <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">{{ trans(key="remove_filter", lang=lang) }}</a>
       </small>
     {%- endif %}
     <ul class="blog-posts">
@@ -22,13 +22,13 @@
         </li>
         {% else %}
         <li>
-          No posts yet
+          {{ trans(key="no_posts", lang=lang) }}
         </li>
       {% endfor %}
     </ul>
     <small>
       <div>
-        {% set tags = get_taxonomy(kind="tags") %}
+        {% set tags = get_taxonomy(kind="tags", lang=lang) %}
         {% for post in tags.items %}
           <a href="{{ post.permalink }}">#{{ post.name }}</a>&nbsp;
         {% endfor %}
diff --git a/templates/security_tags.html b/templates/security_tags.html
new file mode 100644
index 0000000..0f922ea
--- /dev/null
+++ b/templates/security_tags.html
@@ -0,0 +1,2 @@
+<!-- These tags are here for demostration. It's recommended to send them via HTTP headers instead. -->
+<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self'; object-src 'none'; script-src 'none'; style-src 'unsafe-inline'">
diff --git a/templates/seo_tags.html b/templates/seo_tags.html
index 797569a..4eb2bc8 100644
--- a/templates/seo_tags.html
+++ b/templates/seo_tags.html
@@ -1 +1,2 @@
 <meta name="title" content="{% if page.title %}{{ page.title }}{% else %}{{ config.title }}{% endif %}">
+<meta name="description" content="{{ config.description }}" />
diff --git a/templates/style.html b/templates/style.css.html
index 4744695..716880d 100644
--- a/templates/style.html
+++ b/templates/style.css.html
@@ -1,4 +1,3 @@
-<style>
   body {
     font-family: Verdana, sans-serif;
     margin: auto;
@@ -32,14 +31,27 @@
     border: 0;
   }
 
+  .title h1 {
+  font-size: 1.5em;
+  }
+
   .title span {
     font-weight: 400;
   }
 
+  .filter {
+    margin-bottom: 0;
+  }
+
   nav a {
     margin-right: 10px;
   }
 
+  nav active {
+    font-weight: bold;
+    margin-right: 10px;
+  }
+
   textarea {
     width: 100%;
     font-size: 1rem;
@@ -168,5 +180,3 @@
       color: #aaa;
     }
   }
-
-</style>
diff --git a/templates/taxonomy_list.html b/templates/taxonomy_list.html
index 69d9fa2..4b4e08a 100644
--- a/templates/taxonomy_list.html
+++ b/templates/taxonomy_list.html
@@ -2,9 +2,10 @@
 
 {% block main %}
   <main>
+    <h1>{{ taxonomy.name | capitalize }}</h1>
     <small>
       <div>
-        {% set tags = get_taxonomy(kind="tags") %}
+        {% set tags = get_taxonomy(kind="tags", lang=lang) %}
         {% for post in tags.items %}
           <a href="{{ post.permalink }}">#{{ post.name }}</a>&nbsp;
         {% endfor %}
diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html
index d5712b0..9c9cebb 100644
--- a/templates/taxonomy_single.html
+++ b/templates/taxonomy_single.html
@@ -2,10 +2,10 @@
 
 {% block main %}
   <main>
-    {%- if taxonomy.term %}
-      <h3 style="margin-bottom:0">Filtering for "{{ term.name }}"</h3>
+    {%- if term %}
+      <h3 class="filter">Filtering for "{{ term.name }}"</h3>
       <small>
-        <a href="{{ get_url(path="@/blog/_index.md") }}">Remove filter</a>
+        <a href="{{ get_url(path="@/blog/_index.md", lang=lang) }}">{{ trans(key="remove_filter", lang=lang) }}</a>
       </small>
     {%- endif %}
     <ul class="blog-posts">
@@ -22,7 +22,7 @@
         </li>
       {% else %}
         <li>
-          No posts yet
+          {{ trans(key="no_posts", lang=lang) }}
         </li>
       {% endfor %}
     </ul>