Last active
October 24, 2022 02:02
-
-
Save shinokada/9af523ae9fd4450a0e05e3194b04a96e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // src/routes/blog/[slug]/+page.js | |
| import { error } from '@sveltejs/kit'; | |
| /** @type {import('./$types').PageLoad} */ | |
| export async function load({ params }) { | |
| const post = await import(`../${params.slug}.md`); | |
| const { title, dir } = post.metadata; | |
| const content = post.default; | |
| return { | |
| content, | |
| title, | |
| dir | |
| }; | |
| throw error(404, 'Not found'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment