mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-20 01:11:20 +08:00
18 lines
585 B
Plaintext
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);
|
|
---
|