Add Netlify _redirects for pretty URLs with proper 301 redirects

This commit is contained in:
Obsidian Sync 2026-02-25 19:06:31 +05:30
parent 9af0acc294
commit f478bd6f0a
4 changed files with 46 additions and 17 deletions

View file

@ -1,16 +0,0 @@
---
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);
---