--- import { getCollection } from "astro:content"; import PostLayout from "../../layouts/PostLayout.astro"; import * as collections from "../../content/config"; import type { PostCollection, AnyCollectionEntry } from "../../types"; export async function getStaticPaths() { const categories = Object.keys(collections.collections).filter( (c) => c !== "git" && c !== "gists", ) as PostCollection[]; const entries: Array<{ params: { category: string; slug: string }; props: { post: AnyCollectionEntry }; }> = []; for (const category of categories) { const docs = await getCollection(category); for (const doc of docs) { entries.push({ params: { category, slug: doc.slug }, props: { post: doc }, }); } } return entries; } interface Props { post: AnyCollectionEntry; } const { post } = Astro.props; const category = Astro.params.category; const { Content, headings } = await post.render(); const pageTitle = `${category}/${post.data.title ?? post.slug}`; if (post.data?.redirect) { return Astro.redirect(post.data.redirect, 301); } --- {pageTitle}