Add pretty URL redirects: /slug -> /blog/slug

This commit is contained in:
Obsidian Sync 2026-02-25 18:51:28 +05:30
parent 77fb20abe4
commit 9af0acc294

16
src/pages/[...id].astro Normal file
View file

@ -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);
---