From 07b11063a12448fd22df7c18e3d016ab8fdb008e Mon Sep 17 00:00:00 2001 From: echus Date: Tue, 23 Jan 2024 18:57:52 +1100 Subject: [PATCH] Make people variable optional --- src/pages/people/[...slug].astro | 29 ++++++++++++----------------- src/pages/people/index.astro | 8 +++----- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/pages/people/[...slug].astro b/src/pages/people/[...slug].astro index 1d54a49..f658394 100644 --- a/src/pages/people/[...slug].astro +++ b/src/pages/people/[...slug].astro @@ -1,26 +1,21 @@ --- import { type CollectionEntry, getCollection } from "astro:content"; +import Person from "../../layouts/Person.astro"; + export async function getStaticPaths() { - return []; + const people = await getCollection("people"); + console.log("people", people); + return people.map((person) => ({ + params: { slug: person.slug }, + props: person, + })); } -// import Person from "../../layouts/Person.astro"; -// -// export async function getStaticPaths() { -// const people = await getCollection("people"); -// console.log("people", people); -// return people.map((person) => ({ -// params: { slug: person.slug }, -// props: person, -// })); -// } -// type Props = CollectionEntry<"people">; -// -// const person = Astro.props; -// const { Content } = await person.render(); +type Props = CollectionEntry<"people">; + +const person = Astro.props; +const { Content } = await person.render(); --- - diff --git a/src/pages/people/index.astro b/src/pages/people/index.astro index 8f32226..7795480 100644 --- a/src/pages/people/index.astro +++ b/src/pages/people/index.astro @@ -3,10 +3,10 @@ import BaseHead from "../../components/BaseHead.astro"; import Header from "../../components/Header.astro"; import Footer from "../../components/Footer.astro"; import { SITE_TITLE, SITE_DESCRIPTION } from "../../consts"; -// import { getCollection } from "astro:content"; +import { getCollection } from "astro:content"; import FormattedDate from "../../components/FormattedDate.astro"; -// const people = await getCollection("people"); +const people = await getCollection("people"); --- @@ -19,10 +19,9 @@ import FormattedDate from "../../components/FormattedDate.astro";
-