mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37: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" %}
|
||||
|
||||
{% import "macros.html" as macros %}
|
||||
{% import "edition-1/macros.html" as macros %}
|
||||
|
||||
{% 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" %}
|
||||
|
||||
{% import "macros.html" as macros %}
|
||||
{% import "edition-1/macros.html" as macros %}
|
||||
|
||||
{% block title %}{{ section.title }} | {{ config.title }}{% endblock title %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user