This commit is contained in:
2026-02-12 23:54:49 +01:00
commit 724500ae0b
16 changed files with 575 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { getParams, htmlToResponse, readDir } from "@mastrojs/mastro";
import { readMarkdownFile } from "@mastrojs/markdown";
import { Layout } from "../../../components/Layout.ts";
export const GET = async (req: Request) => {
const { slug } = getParams(req);
const post = await readMarkdownFile(`data/posts/${slug}.md`);
return htmlToResponse(
Layout({
title: post.meta.title,
children: post.content,
}),
);
};
export const getStaticPaths = async () => {
const posts = await readDir("data/posts/");
return posts.map((p) => "/news/" + p.slice(0, -3) + "/");
};