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>

View File

@@ -2,7 +2,7 @@
title: Async Iterator::map
author: lbfalvy
tags: [programming, rust, langdev]
pubDate: 2025-01-30T17:00Z[UTC]
pubDate: 2025-01-29T10:58Z[UTC]
summary: On the state of async Rust, limitations of the type system, and Iterator::map
unlisted: false
---

View File

@@ -2,6 +2,7 @@
import type { CollectionEntry } from 'astro:content';
import Main from './Main.astro';
import { parseTime, printTime } from '../utils/time';
import Time from '../components/Time.svelte';
type Props = CollectionEntry<'blog'>['data'];
@@ -12,12 +13,10 @@ const { title, author, summary, pubDate, updatedDate } = Astro.props;
<header class="lg:grid grid-cols-[auto_auto_minmax(300px,_1fr)] grid-rows-[auto_auto]">
<h2 class="font-bold row-span-2 text-2xl m-2 mt-3">{title}</h2>
<address class="post-meta inline-block col-start-2">{author}</address>
<time datetime={parseTime(pubDate).toString()}
class="post-meta inline-block col-start-3"
>{printTime(parseTime(pubDate))}</time>
<Time time={parseTime(pubDate)} />
<div class="italic tracking-[3px] text-emph-fg col-start-2 col-span-2 m-2 mt-0">{summary}</div>
{updatedDate && <div>
Amended <time datetime={parseTime(updatedDate).toString()}>{printTime(parseTime(updatedDate))}</time>
Amended <Time time={parseTime(updatedDate)} />
</div>}
</header>
<hr class="mb-3">