mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-18 07:17:49 +00:00
Move macros
Each edition now has their own macros, so create a macros.html for the third edition too. Since the utterances theme differs between editions, we need to move it from snippets.html to the edition-specific macros.html too.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{% extends "edition-2/base.html" %}
|
{% extends "edition-2/base.html" %}
|
||||||
|
|
||||||
{% import "snippets.html" as snippets %}
|
{% import "edition-2/macros.html" as macros %}
|
||||||
|
|
||||||
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
@@ -17,6 +17,6 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<section>
|
<section>
|
||||||
<h2>Comments</h2>
|
<h2>Comments</h2>
|
||||||
{{ snippets::utterances() }}
|
{{ macros::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
{% endblock after_main %}
|
{% endblock after_main %}
|
||||||
|
|||||||
@@ -26,43 +26,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endmacro post_link %}
|
{% endmacro post_link %}
|
||||||
|
|
||||||
{% macro post_link_edition_3(page) %}
|
|
||||||
<div>
|
|
||||||
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
|
|
||||||
{%- if translations -%}
|
|
||||||
{%- set post = get_page(path = translations.0.path) -%}
|
|
||||||
{%- else -%}
|
|
||||||
{%- set post = page -%}
|
|
||||||
{%- set not_translated = true -%}
|
|
||||||
{%- endif -%}
|
|
||||||
<h3 class="post-list-title"><a href="{{ post.path | safe }}">{{ post.title }}</a></h3>
|
|
||||||
<span class="post-list-icon">
|
|
||||||
{%- if post.extra.icon -%}{{post.extra.icon | safe}}{%- endif -%}
|
|
||||||
</span>
|
|
||||||
<div class="post-summary">
|
|
||||||
{{ post.summary | safe }}
|
|
||||||
<a class="read-more" href="{{ post.path | safe }}"><em>read more »</em></a>
|
|
||||||
|
|
||||||
{%- if lang and not_translated and lang != config.default_language -%}
|
|
||||||
<aside class="no-translation">
|
|
||||||
(This post is not translated yet.)
|
|
||||||
</aside>
|
|
||||||
{%- endif -%}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endmacro post_link %}
|
|
||||||
|
|
||||||
|
|
||||||
{% macro utterances_edition_3() %}
|
|
||||||
<script src="https://utteranc.es/client.js"
|
|
||||||
data-repo="phil-opp/blog_os"
|
|
||||||
data-issue-term="url"
|
|
||||||
data-label="comments"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
theme="preferred-color-scheme"
|
|
||||||
async>
|
|
||||||
</script>
|
|
||||||
{% endmacro utterances_edition_3 %}
|
|
||||||
{% macro toc(toc) %}
|
{% macro toc(toc) %}
|
||||||
<details id = "toc-inline">
|
<details id = "toc-inline">
|
||||||
<summary><b>Table of Contents</b></summary>
|
<summary><b>Table of Contents</b></summary>
|
||||||
@@ -79,3 +42,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
{% endmacro toc %}
|
{% endmacro toc %}
|
||||||
|
|
||||||
|
{% macro utterances() %}
|
||||||
|
<script src="https://utteranc.es/client.js"
|
||||||
|
data-repo="phil-opp/blog_os"
|
||||||
|
data-issue-term="url"
|
||||||
|
data-label="comments"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
async>
|
||||||
|
</script>
|
||||||
|
{% endmacro utterances %}
|
||||||
|
|||||||
25
blog/templates/edition-2/news-page.html
Normal file
25
blog/templates/edition-2/news-page.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "edition-2/base.html" %}
|
||||||
|
|
||||||
|
{% import "edition-2/macros.html" as macros %}
|
||||||
|
|
||||||
|
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>{{ page.title }}</h1>
|
||||||
|
<time datetime="{{ page.date | date(format="%Y-%m-%d") }}" class="post-date">
|
||||||
|
{{ page.date | date(format="%b %d, %Y") }}
|
||||||
|
{% if page.extra.updated %} (updated on {{ page.extra.updated | date(format="%b %d, %Y") }}) {% endif %}
|
||||||
|
</time>
|
||||||
|
{{ page.content | safe }}
|
||||||
|
{% endblock main %}
|
||||||
|
|
||||||
|
{% block after_main %}
|
||||||
|
<hr>
|
||||||
|
<section>
|
||||||
|
<h2 id="comments">Comments</h2>
|
||||||
|
{{ macros::utterances() }}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{% endblock after_main %}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ snippets::utterances() }}
|
{{ macros::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<aside class="page-aside-right">
|
<aside class="page-aside-right">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends "edition-3/base.html" %}
|
{% extends "edition-3/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "snippets.html" as snippets %}
|
||||||
|
|
||||||
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
@@ -17,6 +17,6 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<section>
|
<section>
|
||||||
<h2>Comments</h2>
|
<h2>Comments</h2>
|
||||||
{{ macros::utterances() }}
|
{{ snippets::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
{% endblock after_main %}
|
{% endblock after_main %}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "edition-3/foundation.html" %}
|
{% extends "edition-3/foundation.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-3/macros.html" as macros %}
|
||||||
|
{% import "snippets.html" as snippets %}
|
||||||
|
|
||||||
{% block title %}{{ config.title }}{% endblock title %}
|
{% block title %}{{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
<li>{{ macros::post_link_edition_3(page=post) }}</li>
|
<li>{{ macros::post_link(page=post) }}</li>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ul></div>
|
</ul></div>
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@
|
|||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<h2>Support Me</h2>
|
<h2>Support Me</h2>
|
||||||
{% include "support.html" %}
|
{{ snippets::support() }}
|
||||||
</div>
|
</div>
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|
||||||
|
|||||||
58
blog/templates/edition-3/macros.html
Normal file
58
blog/templates/edition-3/macros.html
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{% macro latest_post(posts) %}
|
||||||
|
{% set post = posts|last %}
|
||||||
|
<strong><a href="{{ post.path | safe }}">{{ post.title }}</a></strong>
|
||||||
|
{% endmacro latest_post %}
|
||||||
|
|
||||||
|
{% macro post_link(page) %}
|
||||||
|
<div>
|
||||||
|
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
|
||||||
|
{%- if translations -%}
|
||||||
|
{%- set post = get_page(path = translations.0.path) -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set post = page -%}
|
||||||
|
{%- set not_translated = true -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<h3 class="post-list-title"><a href="{{ post.path | safe }}">{{ post.title }}</a></h3>
|
||||||
|
<span class="post-list-icon">
|
||||||
|
{%- if post.extra.icon -%}{{post.extra.icon | safe}}{%- endif -%}
|
||||||
|
</span>
|
||||||
|
<div class="post-summary">
|
||||||
|
{{ post.summary | safe }}
|
||||||
|
<a class="read-more" href="{{ post.path | safe }}"><em>read more »</em></a>
|
||||||
|
|
||||||
|
{%- if lang and not_translated and lang != config.default_language -%}
|
||||||
|
<aside class="no-translation">
|
||||||
|
(This post is not translated yet.)
|
||||||
|
</aside>
|
||||||
|
{%- endif -%}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro post_link %}
|
||||||
|
|
||||||
|
{% macro toc(toc) %}
|
||||||
|
<details id = "toc-inline">
|
||||||
|
<summary><b>Table of Contents</b></summary>
|
||||||
|
<ul>
|
||||||
|
{% for h2 in toc %}<li>
|
||||||
|
<a href="#{{h2.id | safe}}">{{ h2.title | safe }}</a>
|
||||||
|
{% if h2.children %}<ul>
|
||||||
|
{% for h3 in h2.children %}<li>
|
||||||
|
<a href="#{{h3.id | safe}}">{{ h3.title | safe }}</a>
|
||||||
|
</li>{% endfor %}
|
||||||
|
</ul>{% endif %}
|
||||||
|
</li>{% endfor %}
|
||||||
|
<li class="toc-comments-link"><a href="#comments">Comments</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
{% endmacro toc %}
|
||||||
|
|
||||||
|
{% macro utterances() %}
|
||||||
|
<script src="https://utteranc.es/client.js"
|
||||||
|
data-repo="phil-opp/blog_os"
|
||||||
|
data-issue-term="url"
|
||||||
|
data-label="comments"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
theme="preferred-color-scheme"
|
||||||
|
async>
|
||||||
|
</script>
|
||||||
|
{% endmacro utterances %}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "edition-3/base.html" %}
|
{% extends "edition-3/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-3/macros.html" as macros %}
|
||||||
|
{% import "snippets.html" as snippets %}
|
||||||
|
|
||||||
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
||||||
{% block header %}
|
{% block header %}
|
||||||
@@ -80,7 +81,7 @@
|
|||||||
|
|
||||||
<div class="post-footer-support">
|
<div class="post-footer-support">
|
||||||
<h2>Support Me</h2>
|
<h2>Support Me</h2>
|
||||||
{% include "support.html" %}
|
{{ snippets::support() }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -103,7 +104,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ macros::utterances_edition_3() }}
|
{{ macros::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<aside class="page-aside-right">
|
<aside class="page-aside-right">
|
||||||
|
|||||||
@@ -1,25 +1 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "edition-2/news-page.html" %}
|
||||||
|
|
||||||
{% import "snippets.html" as snippets %}
|
|
||||||
|
|
||||||
{% block title %}{{ page.title }} | {{ config.title }}{% endblock title %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<h1>{{ page.title }}</h1>
|
|
||||||
<time datetime="{{ page.date | date(format="%Y-%m-%d") }}" class="post-date">
|
|
||||||
{{ page.date | date(format="%b %d, %Y") }}
|
|
||||||
{% if page.extra.updated %} (updated on {{ page.extra.updated | date(format="%b %d, %Y") }}) {% endif %}
|
|
||||||
</time>
|
|
||||||
{{ page.content | safe }}
|
|
||||||
{% endblock main %}
|
|
||||||
|
|
||||||
{% block after_main %}
|
|
||||||
<hr>
|
|
||||||
<section>
|
|
||||||
<h2 id="comments">Comments</h2>
|
|
||||||
{{ snippets::utterances() }}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{% endblock after_main %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,3 @@
|
|||||||
Thank you!
|
Thank you!
|
||||||
</p>
|
</p>
|
||||||
{% endmacro support %}
|
{% endmacro support %}
|
||||||
|
|
||||||
{% macro utterances() %}
|
|
||||||
<script src="https://utteranc.es/client.js"
|
|
||||||
data-repo="phil-opp/blog_os"
|
|
||||||
data-issue-term="url"
|
|
||||||
data-label="comments"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
async>
|
|
||||||
</script>
|
|
||||||
{% endmacro utterances %}
|
|
||||||
Reference in New Issue
Block a user