38 lines
857 B
Plaintext
38 lines
857 B
Plaintext
---
|
|
import { getCollection, render } from "astro:content";
|
|
import { collectionNames, isSiteCollection } from "../../config/content";
|
|
import Layout from "../../layouts/Layout.astro";
|
|
|
|
export async function getStaticPaths() {
|
|
const paths = [];
|
|
|
|
for (const collection of collectionNames) {
|
|
const entries = await getCollection(collection);
|
|
|
|
for (const entry of entries) {
|
|
paths.push({
|
|
params: {
|
|
collection,
|
|
slug: entry.id === "index" ? undefined : entry.id,
|
|
},
|
|
props: { collection, entry },
|
|
});
|
|
}
|
|
}
|
|
|
|
return paths;
|
|
}
|
|
|
|
const { collection } = Astro.params;
|
|
|
|
if (!collection || !isSiteCollection(collection)) {
|
|
throw new Error("Invalid collection");
|
|
}
|
|
|
|
const { entry } = Astro.props;
|
|
const { Content } = await render(entry);
|
|
---
|
|
|
|
<Layout title={entry.data.title}>
|
|
<Content />
|
|
</Layout> |