2023-08-17 18:34:31 +01:00

28 lines
507 B
TypeScript

interface PostData {
Content: ConstructorOfATypedSvelteComponent;
title: string;
date: string;
author: string;
}
const defaultSlug = 'notFound';
export async function load({ params }) {
let post;
try {
post = await import(`../markdown/${params.slug}.md`);
} catch {
post = await import(`../markdown/${defaultSlug}.md`);
}
const { title, date, author } = post.metadata;
const Content = post.default;
const postData: PostData = {
Content,
title,
date,
author
};
return postData;
}