Skip to content

Commit

Permalink
Make people variable optional
Browse files Browse the repository at this point in the history
  • Loading branch information
echus committed Jan 23, 2024
1 parent 8e066c4 commit 07b1106
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
29 changes: 12 additions & 17 deletions src/pages/people/[...slug].astro
Original file line number Diff line number Diff line change
@@ -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();
---

<!--
<Person {...person.data}>
<Content />
</Person>
-->
8 changes: 3 additions & 5 deletions src/pages/people/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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");
---

<!doctype html>
Expand All @@ -19,10 +19,9 @@ import FormattedDate from "../../components/FormattedDate.astro";
<Header />
<main>
<section>
<!--
<ul>
{
people.map((person) => (
people?.map((person) => (
<li>
<a href={`/people/${person.slug}/`}>
<h4 class="title">{person.data.name}</h4>
Expand All @@ -31,7 +30,6 @@ import FormattedDate from "../../components/FormattedDate.astro";
))
}
</ul>
-->
</section>
</main>
<Footer />
Expand Down

0 comments on commit 07b1106

Please sign in to comment.