Skip to content

Instantly share code, notes, and snippets.

@shinokada
Last active October 24, 2022 02:02
Show Gist options
  • Save shinokada/9af523ae9fd4450a0e05e3194b04a96e to your computer and use it in GitHub Desktop.
Save shinokada/9af523ae9fd4450a0e05e3194b04a96e to your computer and use it in GitHub Desktop.
// 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