Further work

This commit is contained in:
Fred Boniface 2023-08-17 18:34:31 +01:00
parent e78f3a4a76
commit 792750fa37
9 changed files with 27 additions and 0 deletions

View File

View File

@ -0,0 +1,27 @@
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;
}