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 { onMount } from "svelte";
import { SvelteMap } from "svelte/reactivity"; import { SvelteMap } from "svelte/reactivity";
import { parseTime, printTime } from "../utils/time"; import { parseTime, printTime } from "../utils/time";
import Time from "./Time.svelte";
interface Props { interface Props {
posts: CollectionEntry<"blog">[]; posts: CollectionEntry<"blog">[];
@@ -69,11 +70,9 @@
<address class="inline-block post-meta col-start-2 md:ml-3"> <address class="inline-block post-meta col-start-2 md:ml-3">
{post.data.author} {post.data.author}
</address> </address>
<time class="inline-block post-meta col-start-3 lg:ml-1" <div class="inline-block post-meta col-start-3 lg:ml-1">
datetime={parseTime(post.data.pubDate).toString()} <Time time={parseTime(post.data.pubDate)} />
> </div>
{printTime(parseTime(post.data.pubDate))}
</time>
<div class="col-span-3">{post.data.summary}</div> <div class="col-span-3">{post.data.summary}</div>
</div> </div>
</a> </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 title: Async Iterator::map
author: lbfalvy author: lbfalvy
tags: [programming, rust, langdev] 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 summary: On the state of async Rust, limitations of the type system, and Iterator::map
unlisted: false unlisted: false
--- ---

View File

@@ -2,6 +2,7 @@
import type { CollectionEntry } from 'astro:content'; import type { CollectionEntry } from 'astro:content';
import Main from './Main.astro'; import Main from './Main.astro';
import { parseTime, printTime } from '../utils/time'; import { parseTime, printTime } from '../utils/time';
import Time from '../components/Time.svelte';
type Props = CollectionEntry<'blog'>['data']; 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]"> <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> <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> <address class="post-meta inline-block col-start-2">{author}</address>
<time datetime={parseTime(pubDate).toString()} <Time time={parseTime(pubDate)} />
class="post-meta inline-block col-start-3"
>{printTime(parseTime(pubDate))}</time>
<div class="italic tracking-[3px] text-emph-fg col-start-2 col-span-2 m-2 mt-0">{summary}</div> <div class="italic tracking-[3px] text-emph-fg col-start-2 col-span-2 m-2 mt-0">{summary}</div>
{updatedDate && <div> {updatedDate && <div>
Amended <time datetime={parseTime(updatedDate).toString()}>{printTime(parseTime(updatedDate))}</time> Amended <Time time={parseTime(updatedDate)} />
</div>} </div>}
</header> </header>
<hr class="mb-3"> <hr class="mb-3">