refactor: ♻️ move post meta into importable macro

This commit is contained in:
Sebin Nyshkim 2024-10-15 22:56:22 +02:00
parent 9f7387c54b
commit 1ebb0e7226
3 changed files with 22 additions and 32 deletions

View file

@ -0,0 +1,18 @@
{% macro postmeta(params) %}
<ul class="flex flex-wrap items-center gap-4 *:inline-flex *:items-center *:gap-1 *:*:stroke-sky-600">
<li>
{% lucide "calendar", {"size": "20"} %}
<time datetime="{{ params.date | isoDate }}" title="{{ params.date | longDate }}">
{{ params.date | readableDate }}
</time>
</li>
<li>
{% lucide "user", {"size": "20"} %}
<a href="{{ params.author.href }}">{{ params.author.name }}</a>
</li>
<li>
{% lucide "glasses", {"size": "20"} %}
{{ params.content | readingtime }}
</li>
</ul>
{% endmacro %}

View file

@ -5,22 +5,8 @@ layout: base.njk
<article class="prose prose-slate mx-auto md:prose-lg lg:prose-xl dark:prose-invert prose-headings:font-normal prose-strong:text-inherit prose-li:marker:!text-inherit prose-th:font-bold prose-img:rounded-3xl">
<h1 class="text-4xl">{{ title }}</h1>
<aside class="not-prose space-y-4 text-base">
<ul class="flex flex-wrap items-center gap-4 *:inline-flex *:items-center *:gap-1 *:*:stroke-sky-600">
<li>
{% lucide "calendar", {"size": "20"} %}
<time datetime="{{ page.date | isoDate }}" title="{{ page.date | longDate }}">
{{ page.date | readableDate }}
</time>
</li>
<li>
{% lucide "user", {"size": "20"} %}
<a href="{{ author.href }}">{{ author.name }}</a>
</li>
<li>
{% lucide "glasses", {"size": "20"} %}
{{ content | readingtime }}
</li>
</ul>
{%- from 'postmeta.macro.njk' import postmeta %}
{{ postmeta({ date: page.date, author: author, content: content}) }}
{% if tags.length > 0 %}
<ul class="flex gap-1">
{% for tag in tags %}

View file

@ -15,22 +15,8 @@ pagination:
<article class="prose prose-slate mx-auto md:prose-lg lg:prose-xl dark:prose-invert prose-headings:font-normal prose-strong:text-inherit prose-li:marker:!text-inherit prose-th:font-bold prose-img:rounded-3xl">
<h1>{{ post.data.title }}</h1>
<aside class="not-prose space-y-4 text-base">
<ul class="flex flex-wrap items-center gap-4 *:inline-flex *:items-center *:gap-1 *:*:stroke-sky-600">
<li>
{% lucide "calendar", {"size": "20"} %}
<time datetime="{{ post.date | isoDate }}" title="{{ post.date | longDate }}">
{{ post.date | readableDate }}
</time>
</li>
<li>
{% lucide "user", {"size": "20"} %}
<a href="{{ post.data.author.href }}">{{ post.data.author.name }}</a>
</li>
<li>
{% lucide "glasses", {"size": "20"} %}
{{ post.content | readingtime }}
</li>
</ul>
{%- from 'postmeta.macro.njk' import postmeta %}
{{ postmeta({ date: post.date, author: post.data.author, content: post.content}) }}
</aside>
{% if post.data.image and post.data.image.src != '' %}