From f17061b4cb81d67234f504af6d4220792beecb49 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sat, 25 Apr 2026 13:10:06 +0100 Subject: [PATCH] adds microlog posts to website --- website/src/pages/microlog/[...slug].astro | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 website/src/pages/microlog/[...slug].astro diff --git a/website/src/pages/microlog/[...slug].astro b/website/src/pages/microlog/[...slug].astro new file mode 100644 index 0000000..69c94b0 --- /dev/null +++ b/website/src/pages/microlog/[...slug].astro @@ -0,0 +1,26 @@ +--- +import { type CollectionEntry, getCollection, render } from 'astro:content'; +import MicrologPost from '../../layouts/MicrologPost.astro'; +import { renderGemtextToHtml } from '../../renderGemtextToHtml'; + +export async function getStaticPaths() { + const posts = await getCollection('microlog'); + return posts.map((post) => ({ + params: { slug: post.id }, + props: post, + })); +} +type Props = CollectionEntry<'microlog'>; + +const { id: slug, body } = Astro.props; +const pubDateStr = slug.replaceAll(/\.[0-9]+/g, ''); +const pubDate = new Date(pubDateStr); +if (isNaN(pubDate.valueOf())) { + throw new Error(`Could not construct a valid publication date for microlog post: ${slug}`); +} +const Content = renderGemtextToHtml(body ?? '', pubDateStr); +--- + + + +