mat.services/templates/macros/macros.html

129 lines
3.5 KiB
HTML
Raw Normal View History

2022-10-21 06:26:16 +00:00
{% macro list_posts(pages) -%}
2022-08-13 04:47:49 +00:00
<ul>
{%- for page in pages %}
{%- if page.draft %}
2022-10-21 06:26:16 +00:00
{%- continue -%}
2022-08-13 04:47:49 +00:00
{% endif -%}
2022-08-14 16:06:03 +00:00
<li class="post-list-item">
<h2 class="title">
2022-08-13 04:47:49 +00:00
<a href={{ page.permalink }}>{{page.title}}</a>
2022-08-14 16:06:03 +00:00
</h2>
2022-10-21 06:26:16 +00:00
{%- if page.description %}
2022-09-16 16:57:45 +00:00
<div class="description">
{{ page.description }}
</div>
2022-10-21 06:26:16 +00:00
{%- elif page.summary %}
2022-09-16 16:57:45 +00:00
<div class="description">
{{ page.summary }}&hellip;
</div>
2022-10-21 06:26:16 +00:00
{%- endif %}
2022-08-14 13:46:13 +00:00
<div class="meta">
posted on <time>{{ page.date | date(format="%Y-%m-%d") }}</time>
2022-08-13 04:47:49 +00:00
</div>
2022-10-21 06:26:16 +00:00
{{- post_macros::tags(page=page) -}}
2022-08-14 16:06:03 +00:00
</li>
2022-08-13 04:47:49 +00:00
{% endfor -%}
</ul>
2022-10-21 06:26:16 +00:00
{% endmacro list_posts -%}
2022-08-13 04:47:49 +00:00
2022-10-21 06:26:16 +00:00
{%- macro tags(page) %}
2022-08-13 04:47:49 +00:00
{%- if page.taxonomies and page.taxonomies.tags %}
2022-08-14 13:46:13 +00:00
<span class="meta post-tags-inline">
<span>tagged with </span>
2022-08-13 04:47:49 +00:00
{%- for tag in page.taxonomies.tags %}
<a class="post-tag" href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}">#{{ tag }}</a>
2022-08-14 13:46:13 +00:00
{%- if not loop.last %},{% endif -%}
2022-10-21 06:26:16 +00:00
{% endfor %}
2022-08-13 04:47:49 +00:00
</span>
{% endif -%}
2022-10-21 06:26:16 +00:00
{% endmacro tags -%}
2022-08-13 04:47:49 +00:00
2022-10-21 06:26:16 +00:00
{%- macro page_header(title) -%}
<h1 class="page-header">{{ title }}<span class="primary-color header-dot">.</span></h1>
{%- endmacro content %}
2022-08-13 04:47:49 +00:00
{% macro content(page) %}
2022-08-14 17:05:50 +00:00
<article>
<div class="title">
{{ post_macros::page_header(title=page.title) }}
2022-10-21 06:26:16 +00:00
{%- if page.date %}
2022-08-14 17:05:50 +00:00
<div class="meta">
Posted on <time>{{ page.date | date(format="%Y-%m-%d") }}</time>
2022-10-21 06:26:16 +00:00
{%- if page.draft %}
2022-08-14 17:05:50 +00:00
<span class="draft-label">DRAFT</span>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-13 04:47:49 +00:00
</div>
2022-08-14 17:05:50 +00:00
{% if page.updated %}
<div class="meta">
Updated on <time>{{ page.updated | date(format="%Y-%m-%d") }}</time>
2022-08-13 04:47:49 +00:00
</div>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-14 17:05:50 +00:00
<div class="meta">
{{ page.word_count }} words, {{ page.reading_time }} minute read
</div>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-14 17:05:50 +00:00
</div>
2022-10-21 06:26:16 +00:00
{%- if page.extra.hero %}
2022-10-10 23:12:16 +00:00
<figure>
2022-10-21 06:26:16 +00:00
<img width=1024 height=512 class="hero" alt="{{ page.extra.heroPrompt }} - generated using Stable Diffusion" src=hero.webp />
2022-10-10 23:12:16 +00:00
<figcaption>
2022-10-17 01:25:58 +00:00
<p><i>{{ page.extra.heroPrompt }}</i> - generated using Stable Diffusion</p>
2022-10-10 23:12:16 +00:00
</figcaption>
</figure>
2022-10-21 06:26:16 +00:00
{% endif -%}
{%- if page.extra.tldr %}
2022-08-14 17:05:50 +00:00
<div class="tldr">
<strong>tl;dr:</strong>
{{ page.extra.tldr }}
</div>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-14 17:05:50 +00:00
{# Optional table of contents #}
2022-10-21 06:26:16 +00:00
{%- if page.extra.toc | default(value=false) %}
{%- if page.toc -%}
2022-08-14 17:05:50 +00:00
<h2>Table of Contents</h2>
<ul>
2022-10-21 06:26:16 +00:00
{%- for h1 in page.toc %}
2022-08-14 17:05:50 +00:00
<li>
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
2022-10-21 06:26:16 +00:00
{%- if h1.children %}
2022-08-14 17:05:50 +00:00
<ul>
2022-10-21 06:26:16 +00:00
{%- for h2 in h1.children %}
2022-08-14 17:05:50 +00:00
<li>
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
</li>
2022-10-21 06:26:16 +00:00
{%- if h2.children %}
2022-08-13 04:47:49 +00:00
<ul>
2022-10-21 06:26:16 +00:00
{%- for h3 in h2.children %}
2022-08-13 04:47:49 +00:00
<li>
2022-08-14 17:05:50 +00:00
<a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
2022-08-13 04:47:49 +00:00
</li>
2022-10-21 06:26:16 +00:00
{% endfor -%}
2022-08-13 04:47:49 +00:00
</ul>
2022-10-21 06:26:16 +00:00
{% endif -%}
{% endfor -%}
2022-08-14 17:05:50 +00:00
</ul>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-14 17:05:50 +00:00
</li>
2022-10-21 06:26:16 +00:00
{% endfor -%}
2022-08-14 17:05:50 +00:00
</ul>
2022-10-21 06:26:16 +00:00
{%- endif -%}
{% endif -%}
2022-08-14 17:05:50 +00:00
<section class="body">
2022-10-21 06:26:16 +00:00
{{ page.content | safe -}}
2022-08-14 17:05:50 +00:00
</section>
2022-10-21 06:26:16 +00:00
{%- if page.taxonomies and page.taxonomies.tags %}
2022-08-14 17:05:50 +00:00
<div class="post-tags">
<span class="meta" id="tagged-with-label">this post is tagged with</span>
<nav class="nav tags" aria-labelledby="tagged-with-label">
<ul class="tags">
2022-10-21 06:26:16 +00:00
{%- for tag in page.taxonomies.tags -%}
2022-08-14 17:05:50 +00:00
<li>
2022-10-21 06:26:16 +00:00
<a href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}">#{{ tag }}</a>
2022-08-14 17:05:50 +00:00
</li>
2022-10-21 06:26:16 +00:00
{% endfor -%}
2022-08-14 17:05:50 +00:00
</ul>
</nav>
</div>
2022-10-21 06:26:16 +00:00
{% endif -%}
2022-08-14 17:05:50 +00:00
</article>
2022-10-21 06:26:16 +00:00
{% endmacro content -%}