mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Restructure macros
- Split macros.html in per-edition files - Create new snippets.html macro file with utterances snippet - Move support.html to snippets.html as new macro - Create new `latest_post` macro in 2nd edition macros.html
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{% extends "edition-1/base.html" %}
|
{% extends "edition-1/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-1/macros.html" as macros %}
|
||||||
|
|
||||||
{% block title %}{{ config.title }}{% endblock title %}
|
{% block title %}{{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
|
|||||||
39
blog/templates/edition-1/macros.html
Normal file
39
blog/templates/edition-1/macros.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{% macro post_link(page) %}
|
||||||
|
{% 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 -%}
|
||||||
|
<div{% if post.extra.rtl %} class="right-to-left"{% endif %}>
|
||||||
|
<h2 class="post-title"><a href="{{ post.path | safe }}">{{ post.title }}</a></h2>
|
||||||
|
<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 %}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends "edition-1/base.html" %}
|
{% extends "edition-1/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-1/macros.html" as macros %}
|
||||||
|
|
||||||
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends "edition-2/base.html" %}
|
{% extends "edition-2/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-2/base.html" %}
|
{% extends "edition-2/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-2/macros.html" as macros %}
|
||||||
|
{% import "snippets.html" as snippets %}
|
||||||
|
|
||||||
{% block title %}{{ config.title }}{% endblock title %}
|
{% block title %}{{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<h2>Support Me</h2>
|
<h2>Support Me</h2>
|
||||||
{% include "support.html" %}
|
{{ snippets::support() }}
|
||||||
</div>
|
</div>
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
{% 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) %}
|
{% macro post_link(page) %}
|
||||||
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
|
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
|
||||||
{%- if translations -%}
|
{%- if translations -%}
|
||||||
@@ -21,16 +26,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endmacro post_link %}
|
{% endmacro post_link %}
|
||||||
|
|
||||||
{% 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 %}
|
|
||||||
|
|
||||||
{% 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>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends "edition-2/base.html" %}
|
{% extends "edition-2/base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
{% import "edition-2/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 %}
|
||||||
@@ -75,7 +76,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>
|
||||||
@@ -98,7 +99,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ macros::utterances() }}
|
{{ snippets::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<aside class="page-aside-right">
|
<aside class="page-aside-right">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "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,7 +17,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<section>
|
<section>
|
||||||
<h2 id="comments">Comments</h2>
|
<h2 id="comments">Comments</h2>
|
||||||
{{ macros::utterances() }}
|
{{ snippets::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% endblock after_main %}
|
{% endblock after_main %}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
|
||||||
|
|
||||||
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{% macro support() %}
|
||||||
<p>
|
<p>
|
||||||
Creating and <a href="{{ get_url(path="@/status-update/_index.md") }}">maintaining</a> this blog and the associated libraries is a lot of work, but I really enjoy doing it. By supporting me, you allow me to invest more time in new content, new features, and continuous maintenance.
|
Creating and <a href="{{ get_url(path="@/status-update/_index.md") }}">maintaining</a> this blog and the associated libraries is a lot of work, but I really enjoy doing it. By supporting me, you allow me to invest more time in new content, new features, and continuous maintenance.
|
||||||
</p>
|
</p>
|
||||||
@@ -6,4 +7,15 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Thank you!
|
Thank you!
|
||||||
</p>
|
</p>
|
||||||
|
{% 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 %}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "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 %}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<section>
|
<section>
|
||||||
<h2 id="comments">Comments</h2>
|
<h2 id="comments">Comments</h2>
|
||||||
{{ macros::utterances() }}
|
{{ snippets::utterances() }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% endblock after_main %}
|
{% endblock after_main %}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% import "macros.html" as macros %}
|
|
||||||
|
|
||||||
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|||||||
Reference in New Issue
Block a user