Add Netlify _redirects for pretty URLs with proper 301 redirects
This commit is contained in:
parent
9af0acc294
commit
f478bd6f0a
4 changed files with 46 additions and 17 deletions
|
|
@ -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);
|
||||
---
|
||||
Loading…
Add table
Add a link
Reference in a new issue