add blog, initial post
This commit is contained in:
15
src/routes/posts/[slug]/+page.ts
Normal file
15
src/routes/posts/[slug]/+page.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const post = await import(`../${params.slug}.md`);
|
||||
|
||||
return {
|
||||
content: post.default,
|
||||
metadata: post.metadata
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(404, `Post not found: ${params.slug}. Error: ${e}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user