mat.services/templates/macros/macros.html

149 lines
3.5 KiB
HTML
Raw Normal View History

2022-08-13 04:47:49 +00:00
{% macro list_posts(pages) %}
<ul>
{%- for page in pages %}
{%- if page.draft %}
{% continue %}
{% 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-08-13 04:47:49 +00:00
2022-09-16 16:57:45 +00:00
{% if page.description %}
<div class="description">
{{ page.description }}
</div>
{% elif page.summary %}
<div class="description">
{{ page.summary }}&hellip;
</div>
{% 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-08-14 13:46:13 +00:00
{{ post_macros::tags(page=page) }}
2022-08-13 04:47:49 +00:00
<br />
2022-08-14 16:06:03 +00:00
</li>
2022-08-13 04:47:49 +00:00
{% endfor -%}
</ul>
{% endmacro list_posts %}
2022-08-14 13:46:13 +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-08-13 04:47:49 +00:00
{% endfor -%}
</span>
{% endif -%}
{% endmacro tags %}
{% macro page_header(title) %}
2022-08-13 23:47:29 +00:00
<h1 class="page-header">
2022-08-13 05:03:55 +00:00
{{ title }}<span class="primary-color header-dot">.</span>
2022-08-13 23:47:29 +00:00
</h1>
2022-08-13 04:47:49 +00:00
{% endmacro content %}
{% macro content(page) %}
2022-08-14 17:05:50 +00:00
<article>
<div class="title">
{{ post_macros::page_header(title=page.title) }}
2022-08-13 04:47:49 +00:00
2022-08-14 17:05:50 +00:00
{% if page.date %}
<div class="meta">
Posted on <time>{{ page.date | date(format="%Y-%m-%d") }}</time>
2022-08-13 04:47:49 +00:00
2022-08-14 17:05:50 +00:00
{% if page.draft %}
<span class="draft-label">DRAFT</span>
2022-08-13 04:47:49 +00:00
{% endif %}
</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>
{% endif %}
2022-08-14 17:05:50 +00:00
<div class="meta">
{{ page.word_count }} words, {{ page.reading_time }} minute read
</div>
{% endif %}
</div>
2022-10-10 23:12:16 +00:00
{% if page.extra.hero %}
<figure>
2022-10-17 00:50:53 +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>
<h4><i>{{ page.extra.heroPrompt }}</i> - generated using Stable Diffusion</h4>
</figcaption>
</figure>
{% endif %}
2022-08-14 17:05:50 +00:00
{% if page.extra.tldr %}
<div class="tldr">
<strong>tl;dr:</strong>
{{ page.extra.tldr }}
</div>
{% endif %}
{# Optional table of contents #}
2022-10-10 23:12:16 +00:00
{% if page.extra.toc | default(value=false) %}
2022-08-14 17:05:50 +00:00
{% if page.toc %}
<h2>Table of Contents</h2>
<ul>
{% for h1 in page.toc %}
<li>
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
{% if h1.children %}
<ul>
{% for h2 in h1.children %}
<li>
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
</li>
{% if h2.children %}
2022-08-13 04:47:49 +00:00
<ul>
2022-08-14 17:05:50 +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>
{% endfor %}
</ul>
{% endif %}
2022-08-14 17:05:50 +00:00
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
<section class="body">
{{ page.content | safe }}
</section>
{% if page.taxonomies and page.taxonomies.tags %}
<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">
{% for tag in page.taxonomies.tags %}
<li>
<a href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}">
#{{ tag }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</div>
{% endif %}
</article>
2022-08-13 04:47:49 +00:00
{% endmacro content %}