made time display client-side

This commit is contained in:
Bethlenfalvi, Lorinc (ext)
2025-01-29 12:00:58 +01:00
parent dae699204b
commit 0db85f6ce5
4 changed files with 22 additions and 10 deletions

View File

@@ -3,6 +3,7 @@
import { onMount } from "svelte";
import { SvelteMap } from "svelte/reactivity";
import { parseTime, printTime } from "../utils/time";
import Time from "./Time.svelte";
interface Props {
posts: CollectionEntry<"blog">[];
@@ -69,11 +70,9 @@
<address class="inline-block post-meta col-start-2 md:ml-3">
{post.data.author}
</address>
<time class="inline-block post-meta col-start-3 lg:ml-1"
datetime={parseTime(post.data.pubDate).toString()}
>
{printTime(parseTime(post.data.pubDate))}
</time>
<div class="inline-block post-meta col-start-3 lg:ml-1">
<Time time={parseTime(post.data.pubDate)} />
</div>
<div class="col-span-3">{post.data.summary}</div>
</div>
</a>

View File

@@ -0,0 +1,14 @@
<script lang="ts">
import type { Temporal } from "@js-temporal/polyfill";
import { printTime } from "../utils/time";
interface Props {
time: Temporal.ZonedDateTime
}
const { time }: Props = $props();
</script>
<time datetime={time.toString()} class="post-meta inline-block col-start-3">
{printTime(time)}
</time>