Add dynamic entries function for post prerendering
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const entries = () => {
|
||||
const posts = import.meta.glob('../*.md', { eager: true });
|
||||
return Object.keys(posts).map((path) => {
|
||||
const slug = path.replace('../', '').replace('.md', '');
|
||||
return { slug };
|
||||
});
|
||||
};
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
try {
|
||||
const post = await import(`../${params.slug}.md`);
|
||||
|
||||
Reference in New Issue
Block a user