feat: article tags link to articles with the same tag

This commit is contained in:
Troy 2025-03-11 20:56:54 +00:00
parent 1b1bbae3ce
commit aa26e7cd55
Signed by: troy
GPG key ID: DFC06C02ED3B4711
10 changed files with 309 additions and 363 deletions

View file

@ -2,7 +2,7 @@
import Layout from "@layouts/Layout.astro";
import Prose from "@components/Prose.astro";
import FormattedDate from "@components/FormattedDate.astro";
import { readingTime } from "@lib/utils";
import { readingTime, createSlug } from "@lib/utils";
import { Icon } from "astro-icon/components";
import RelatedArticles from "@components/RelatedArticles.astro";
@ -76,6 +76,21 @@ const listFormatter = new Intl.ListFormat("en-GB", {
</div>
) : null
}
{
article.data.tags ? (
<div class="flex flex-wrap items-center gap-2">
<Icon name="mdi:tag" />
{article.data.tags.map((tag: any) => (
<a
href={`/tags/${createSlug(tag)}`}
class="underline hover:no-underline"
>
{tag}
</a>
))}
</div>
) : null
}
</div>
<div
class="animate-reveal mx-auto max-w-full opacity-0 [animation-delay:0.2s]"