mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-20 07:57:49 +00:00
Various 3rd edition template improvements
- merge improvements from second edition (e.g. improved light switch, prefered theme in session storage, translation support) - giscus instead of utterances - add an alpha warning - fix error caused by missing posts etc
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
||||
{% block header %}
|
||||
{% if lang != "en" -%}
|
||||
<aside id="all-posts-link"><a href="{{ get_url(path="@/edition-3/_index.md") }}/{{ lang }}" title="All Posts">« All Posts</a></aside>
|
||||
<aside id="all-posts-link"><a href="{{ get_url(path="@/edition-3/_index.md") }}/{{ lang }}" title="All Posts">{{ trans(key="all_posts", lang=lang) }}</a></aside>
|
||||
{%- else -%}
|
||||
<aside id="all-posts-link"><a href="{{ get_url(path="@/edition-3/_index.md") }}" title="All Posts">« All Posts</a></aside>
|
||||
<aside id="all-posts-link"><a href="{{ get_url(path="@/edition-3/_index.md") }}" title="All Posts">{{ trans(key="all_posts", lang=lang) }}</a></aside>
|
||||
{%- endif %}
|
||||
{% endblock header %}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
{%- endblock description %}
|
||||
|
||||
{% block toc_aside %}
|
||||
<aside id="toc-aside">
|
||||
<h2>Table of Contents</h2>
|
||||
<aside id="toc-aside" class="{% if page.extra.rtl %}right-to-left{% endif %}">
|
||||
<h2>{{ trans(key="toc", lang=lang) }}</h2>
|
||||
<ol>
|
||||
{% for h2 in page.toc %}<li>
|
||||
<a href="#{{h2.id | safe}}">{{ h2.title | safe }}</a>
|
||||
@@ -28,7 +28,7 @@
|
||||
</li>{% endfor %}
|
||||
</ol>{% endif %}
|
||||
</li>{% endfor %}
|
||||
<li class="toc-comments-link"><a href="#comments">Comments</a></li>
|
||||
<li class="toc-comments-link"><a href="#comments">{{ trans(key="comments", lang=lang) }}</a></li>
|
||||
</ol>
|
||||
</aside>
|
||||
{% endblock toc_aside %}
|
||||
@@ -47,6 +47,8 @@
|
||||
</time>
|
||||
</div>
|
||||
|
||||
{{ macros::alpha_warning() }}
|
||||
|
||||
{% if page.extra.warning %}
|
||||
<div class="warning">
|
||||
{% if page.extra.warning_short %} <b>{{ page.extra.warning_short }}</b> {% endif %}
|
||||
@@ -55,18 +57,20 @@
|
||||
{% endif %}
|
||||
|
||||
{%- if page.lang != "en" %}
|
||||
<div class="warning">
|
||||
<div class="warning{% if page.extra.rtl %} right-to-left{% endif %}">
|
||||
{% set translations = page.translations | filter(attribute="lang", value="en") %}
|
||||
{% set original = translations.0 %}
|
||||
<p>
|
||||
<b>Translated Content:</b>
|
||||
This is a community translation of the <strong><a href="{{ original.permalink }}">{{ original.title }}</a></strong> post. It might be incomplete, outdated or contain errors. Please report any issues!
|
||||
<b>{{ trans(key="translated_content", lang=lang) }}</b>
|
||||
{{ trans(key="translated_content_notice", lang=lang) |
|
||||
replace(from="_original.permalink_", to=original.permalink) |
|
||||
replace(from="_original.title_", to=original.title) | safe }}
|
||||
</p>
|
||||
{%- if page.extra.translators %}
|
||||
<p>
|
||||
Translation by {% for user in page.extra.translators -%}
|
||||
{{ trans(key="translated_by", lang=lang) }} {% for user in page.extra.translators -%}
|
||||
{%- if not loop.first -%}
|
||||
{%- if loop.last %}, and {% else %}, {% endif -%}
|
||||
{%- if loop.last %} {{ trans(key="word_separator", lang=lang) }} {% else %}, {% endif -%}
|
||||
{%- endif -%}
|
||||
<a href="https://github.com/{{user}}">@{{user}}</a>
|
||||
{%- endfor %}.
|
||||
@@ -75,11 +79,11 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="{% if page.extra.rtl %}right-to-left{% endif %}">
|
||||
<div class="{% if page.extra.rtl %}right-to-left{% endif %}">
|
||||
{{ page.content | replace(from="<!-- toc -->", to=macros::toc(toc=page.toc)) | safe }}
|
||||
</div>
|
||||
|
||||
<div class="post-footer-support">
|
||||
<div class="post-footer-support{% if page.extra.rtl %} right-to-left{% endif %}">
|
||||
<h2>Support Me</h2>
|
||||
{{ snippets::support() }}
|
||||
</div>
|
||||
@@ -98,41 +102,41 @@
|
||||
|
||||
<hr>
|
||||
<section>
|
||||
<h2 id="comments">Comments</h2>
|
||||
<h2 id="comments" class="{% if page.extra.rtl %}right-to-left{% endif %}">{{ trans(key="comments", lang=lang) }}</h2>
|
||||
|
||||
{% if page.extra.comments_search_term %}
|
||||
{% set search_term=page.extra.comments_search_term %}
|
||||
{% elif page.lang != "en" %}
|
||||
{% set translations = page.translations | filter(attribute="lang", value="en") %}
|
||||
{% set original = translations.0 %}
|
||||
{% set search_term=original.title ~ " (" ~ page.lang ~ ")" %}
|
||||
{% else %}
|
||||
{% set search_term=page.title %}
|
||||
{% endif %}
|
||||
{{ snippets::giscus(search_term=search_term) }}
|
||||
|
||||
{%- if page.lang != "en" %}
|
||||
<p>
|
||||
Please leave your comments in English if possible.
|
||||
<p class="{% if page.extra.rtl %}right-to-left{% endif %}">
|
||||
{{ trans(key="comments_notice", lang=lang) }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{{ macros::utterances() }}
|
||||
</section>
|
||||
|
||||
<aside class="page-aside-right">
|
||||
{% if page.translations -%}
|
||||
{% if page.translations | length > 1-%}
|
||||
<div class="block" id="language-selector">
|
||||
<h2>Other Languages</h2>
|
||||
<ul>{%- for translation in page.translations | sort(attribute="lang") %}
|
||||
<li data-lang-switch-to="{{ translation.lang }}" class=""><a href="{{ translation.permalink | safe }}">
|
||||
{%- if translation.lang == "en" -%}
|
||||
English (original)
|
||||
{%- else -%}
|
||||
{% set translations = page.translations | group_by(attribute="lang") %}
|
||||
<ul>{%- for lang_code in config.extra.languages -%}{%- if translations[lang_code] -%}
|
||||
{%- set translation = translations[lang_code] | first -%}
|
||||
{%- if translation and lang_code != lang -%}
|
||||
<li data-lang-switch-to="{{ translation.lang }}" class=""><a href="{{ translation.permalink | safe }}">
|
||||
{{ trans(key="lang_name", lang = translation.lang) }}
|
||||
{%- endif -%}
|
||||
</a></li>
|
||||
{% endfor %}</ul>
|
||||
</a></li>
|
||||
{%- endif -%}
|
||||
{%- endif -%}{% endfor %}</ul>
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
<div class="block">
|
||||
<h2>About Me</h2>
|
||||
<p>
|
||||
I'm a Rust freelancer with a master's degree in computer science. I love systems programming, open source software, and new challenges.
|
||||
</p><p>
|
||||
If you want to work with me, reach out on <a href = "https://www.linkedin.com/in/phil-opp/">LinkedIn</a> or write me at <a href="mailto:job@phil-opp.com">job@phil-opp.com</a>.
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{% endblock main %}
|
||||
|
||||
Reference in New Issue
Block a user