tags refactor to component

This commit is contained in:
matthieu42morin 2024-04-28 01:24:07 +02:00
parent 8c425f89c8
commit 31fdc9a654
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<script lang="ts">
import type { Post } from '$lib/types/post';
import { formatDate } from '$lib/utils/blog';
export let post: Post;
</script>
<section class="flex-auto flex justify-between items-center py-4 px-2 m-8">
{#if post.tags && post.tags.length > 0}
<div class="flex mb-2 items-center gap-2">
tags: {#each post.tags as tag}
<a
data-sveltekit-preload-data="hover"
href="/{post.type}{new URLSearchParams({ tag }).toString()}"
>
<span class="chip variant-ghost-surface">{tag}</span>
</a>
{/each}
</div>
{/if}
<small>On {formatDate(post.datePublished)}</small>
</section>