Files
kazoottt-blog-v2/src/pages/blog/[...slug].astro
2025-02-12 11:28:42 +08:00

18 lines
585 B
Plaintext

---
import { getAllPosts } from "@/data/post";
import type { GetStaticPaths } from "astro";
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
export const getStaticPaths = (async () => {
const blogEntries = await getAllPosts();
return blogEntries.map((post) => ({
params: { slug: post.id },
props: { post },
}));
}) satisfies GetStaticPaths;
const currentPath = Astro.url.pathname;
const newPath = currentPath.replace("/blog/", "/posts/");
return Astro.redirect(newPath);
---