feat: add reusable macros

This commit is contained in:
Devin Haska 2024-02-19 11:52:18 -08:00
parent a8555c4e89
commit 28baa94b93
5 changed files with 20 additions and 21 deletions

View file

@ -0,0 +1,5 @@
{% macro format(dateString) %}
<time class="[ date ] [ flex items-center gap-0.5 my-1 ]" datetime="{{ date }}">
{% include "svgs/calendar.svg" %}{{ dateString | formatDate("MMMM Do YYYY") }}
</time>
{% endmacro %}

View file

@ -0,0 +1,7 @@
{% macro list(tags) %}
{% if tags | length > 0 %}
<ul class="[ flex list-none p-0 gap-0.5 mb-0 ]">
{% for tag in tags %}<li class="[ bg-surface radius-1 px-1 py-0.5 ]">{{ tag }}</li>{% endfor %}
</ul>
{% endif %}
{% endmacro %}

View file

@ -4,10 +4,8 @@ layout: base
{% set filteredTags = tags | filterCatalogueTags %}
<article class="[ catalogue ] [ flow ]">
<time class="[ date ] [ flex items-center gap-0.5 my-1 ]"
datetime="{{ date }}">
{% include "svgs/calendar.svg" %}
{{ date | formatDate("MMMM Do YYYY") }}</time>
{% from "macros/date.njk" import format %}
{{ format(date) }}
<section class="[ catalogue-meta ] [ gap-1 mb-1 ]">
{% if image %}
{% image image, "", "" %}
@ -16,11 +14,8 @@ layout: base
<h1>{{ title }}</h1>
{% if subtitle %}<h3 class="[ text-fadeText my-0.5 ]">{{ subtitle }}</h3>{% endif %}
{% if author %}<span class="[ text-fadeText ]">by</span> {{ author }}{% endif %}
{% if filteredTags | length > 0 %}
<ul class="[ flex list-none p-0 gap-0.5 ]">
{% for tag in filteredTags %}<li class="[ bg-surface radius-1 px-1 py-0.5 ]">{{ tag }}</li>{% endfor %}
</ul>
{% endif %}
{% import "macros/tags.njk" as tags %}
{{ tags.list(filteredTags) }}
</div>
</section>
{{ content | safe }}

View file

@ -4,10 +4,8 @@ layout: base
{% set filteredTags = tags | filterCatalogueTags %}
<article class="[ catalogue ] [ flow ]">
<time class="[ date ] [ flex items-center gap-0.5 my-1 ]"
datetime="{{ date }}">
{% include "svgs/calendar.svg" %}
{{ date | formatDate("MMMM Do YYYY") }}</time>
{% from "macros/date.njk" import format %}
{{ format(date) }}
<section class="[ catalogue-meta ] [ gap-1 mb-1 ]">
{% if image %}
{% image image, "", "" %}
@ -15,11 +13,6 @@ layout: base
<div>
<h1>{{ title }}</h1>
<h2 class="[ text-fadeText my-0.5 ]">{{ year }}</h2>
{% if filteredTags | length > 0 %}
<ul class="[ flex list-none p-0 gap-0.5 mb-0 ]">
{% for tag in filteredTags %}<li class="[ bg-surface radius-1 px-1 py-0.5 ]">{{ tag }}</li>{% endfor %}
</ul>
{% endif %}
</div>
</section>
{{ content | safe }}

View file

@ -4,9 +4,8 @@ layout: base
<article class="[ flow ]">
<header class="[ flow ]" style="--flow-space: 1rem">
<time class="[ date ][ flex items-center gap-0.5 ]" datetime="{{ date }}">
{% include "svgs/calendar.svg" %}
{{ date | formatDate("MMMM D, YYYY") }}</time>
{% from "macros/date.njk" import format %}
{{ format(date) }}
<h1>{{ title }}</h1>
<ul class="[ categories ] [ flex gap-1 list-none p-0 ]">
{% for tag in tags | filter(["post"]) %}