Files
caperren-com/src/pages/hobby/[id].astro
Corwin Perren 462b08911d
All checks were successful
Build and Test / determine_version (push) Successful in 6s
Build and Test / test (push) Successful in 2s
Build and Test / build_and_push (push) Successful in 39s
Improved tagging
2025-03-08 01:14:48 -08:00

18 lines
586 B
Plaintext

---
import {getCollection, render} from 'astro:content';
import BaseLayout from "../../layouts/BaseLayout.astro";
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const hobbies = await getCollection('hobbies');
return hobbies.map(hobby => ({
params: {id: hobby.id},
props: {hobby: hobby, title: hobby.id},
}));
}
// 2. For your template, you can get the entry directly from the prop
const {hobby} = Astro.props;
const {Content} = await render(hobby);
---
<BaseLayout title={hobby.id}>
<Content/>
</BaseLayout>