💻 Tech
If you have dynamic route, for example posts/20241020
, then you need to define getStaticPaths
in your [slug].astro
file. The slug, which is the file name, should be unique and passed as a route parameters.
export const getStaticPaths = (async () => {
const entries = await getAllPosts();
return entries.map((entry) => {
return { params: { slug: entry.slug, props: { entry } };
});
}) satisfies GetStaticPaths;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;