From a7b926e48eb1a34a72c8123b44438b3d8afef224 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 8 Jun 2020 12:46:18 +0200 Subject: Add translation links in site header. Add translation links in the site header for sections and index. This also moved the header back into the base template, as it seems zola is not able to handle blocks defined in included templates. At least that's what it looked like. Didn't test much. --- config.toml | 2 ++ sass/styles.scss | 7 +++++-- templates/base.html | 8 +++++++- templates/header.html | 4 ---- templates/index.html | 14 +++++--------- templates/section.html | 5 +++++ templates/translation-links.html | 8 ++++++++ 7 files changed, 32 insertions(+), 16 deletions(-) delete mode 100644 templates/header.html create mode 100644 templates/translation-links.html diff --git a/config.toml b/config.toml index 38c9bd6..3aee023 100644 --- a/config.toml +++ b/config.toml @@ -30,6 +30,7 @@ description = "En blogg om samfunn, teknologi, internett, overvåkning og annet moreprompt = "Les mer..." latest = "Siste innlegg:" allposts = "se alle innleggene i" +read_in = "Les på" en = "English" nb = "norsk" @@ -38,6 +39,7 @@ description = "A blog about society, technology, internet, surveillance and othe moreprompt = "More..." latest = "Latest posts:" allposts = "View all posts in" +read_in = "Read in" en = "english" nb = "Norsk" diff --git a/sass/styles.scss b/sass/styles.scss index 0a696bf..76a75ab 100644 --- a/sass/styles.scss +++ b/sass/styles.scss @@ -27,16 +27,19 @@ pre { color: #ccc; font-size: 200%; } - .site-description { + .site-bar { + display: flex; + justify-content: space-between; background-color: #000; color: #ccc; font-size: x-small; } + } .page-content, .site-title, -.site-description { +.site-bar { @media(min-width: 960px) { padding-left: 5rem; padding-right: 5rem; diff --git a/templates/base.html b/templates/base.html index 1d7b588..e1280e2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,13 @@ - {% include "header.html" %} +
diff --git a/templates/header.html b/templates/header.html deleted file mode 100644 index ad0951f..0000000 --- a/templates/header.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/templates/index.html b/templates/index.html index 48857c4..0296444 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,17 +1,13 @@ {% extends "base.html" %} -{% block content %} +{% block language %} +{% set translations = section.translations %} +{% include "translation-links.html" %} +{% endblock language %} +{% block content %}
{{ section.content | safe }}
-
- This page is also available in: - {% for l in section.translations %} - {% if l.lang != lang %} - {{ trans(key=l.lang) }} - {% endif %} - {% endfor %} -
{% for sub in section.subsections %} diff --git a/templates/section.html b/templates/section.html index fed7472..0440afa 100644 --- a/templates/section.html +++ b/templates/section.html @@ -1,4 +1,9 @@ {% extends "base.html" %} +{% block language %} +{% set translations = section.translations %} +{% include "translation-links.html" %} +{% endblock language %} + {% block content %}

{{ section.title }}

diff --git a/templates/translation-links.html b/templates/translation-links.html new file mode 100644 index 0000000..c87f01a --- /dev/null +++ b/templates/translation-links.html @@ -0,0 +1,8 @@ + + {% for l in translations %} + {% if l.lang != lang %} + {{ trans(key="read_in", lang=l.lang) }} + {{ trans(key=l.lang) }} + {% endif %} + {% endfor %} + -- cgit v1.2.3