diff --git a/src/pages/[...id].astro b/src/pages/[...id].astro new file mode 100644 index 0000000..14d6df8 --- /dev/null +++ b/src/pages/[...id].astro @@ -0,0 +1,16 @@ +--- +export const prerender = true; +import { getCollection } from 'astro:content'; + +export async function getStaticPaths() { + const posts = await getCollection('blog'); + + return posts.map((post) => ({ + params: { id: post.id }, + props: { slug: post.id }, + })); +} + +const { slug } = Astro.props; +return Astro.redirect(`/blog/${slug}`, 301); +---