blog/templates/macros/blog.html

60 lines
2 KiB
HTML
Raw Normal View History

2020-02-12 05:46:13 +00:00
{% macro sectionlisting(section) %}
<table style="width: 100%;">
{{ self::postlist(section=section) }}
</table>
{% endmacro postlisting %}
2018-08-09 06:53:47 +00:00
{% macro postlisting(posts) %}
<table style="width: 100%;">
2020-02-12 05:46:13 +00:00
{% for post in posts %}
{{ self::display_post(post=post) }}
{% endfor %}
2018-08-09 06:53:47 +00:00
</table>
{% endmacro postlisting %}
2020-02-12 05:46:13 +00:00
{% macro postlist(section) %}
{% set post_paths = self::recursive_visit(section=section) %}
{% set_global posts = [] %}
{% for path in post_paths | split(pat="&") %}
{% set clean_path = path | trim %}
{% if clean_path == "" %}{% continue %}{% endif %}
{% set post = get_page(path=clean_path) %}
{% set_global posts = posts | concat(with=post) %}
{% endfor %}
{% for post in posts | sort(attribute="date") | reverse %}
{{ self::display_post(post=post) }}
{% endfor %}
{% endmacro %}
{% macro recursive_visit(section) %}
{% if section.extra.include_posts == true %}
{% for page in section.pages %}{{ page.relative_path }}&{% endfor %}
{% for sub in section.subsections %}
{{ self::recursive_visit(section=get_section(path=sub)) }}
{% endfor %}
{% endif %}
{% endmacro %}
{% macro display_post(post) %}
{% if not post.draft %}
<tr class="postlisting-row">
<td>
<span style="font-size: 1.2em;">
<a href="{{ post.permalink }}" class="brand-colorlink">{{ post.title }}</a>
</span>
<br />
<small>
{{ post.reading_time }} min read - Posted {% if post.extra.author %}by {{ post.extra.author }}{% endif %}
on {{ post.date }}
</small>
</td>
{% if post.tags %}
<td style="text-align: right;" class="hidden-sm">
<small>{{ post.tags | join(sep=", ") }}</small>
</td>
{% endif %}
</tr>
{% endif %}
{% endmacro %}