src/pages/blog/[slug].astro

import { getCollection } from "astro:content";

export async function getStaticPaths() {
  const posts = await getCollection("blog");

  // Map each post to a path with its slug
  return posts.map((post) => ({
    params: { slug: post.slug },
    props: { post },
  }));
}