From cbdc98274ef5d671fdf8b3c532523feb02469399 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 17 Nov 2024 20:39:24 -0800 Subject: [PATCH] chore: static paths --- src/pages/books/years/[year].astro | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/books/years/[year].astro b/src/pages/books/years/[year].astro index e8c24f8..aa00cfb 100644 --- a/src/pages/books/years/[year].astro +++ b/src/pages/books/years/[year].astro @@ -13,6 +13,14 @@ import { DateTime } from "luxon"; export const prerender = true; +export async function getStaticPaths() { + const books = await fetchBooks(); + + return books.years.map((yearData) => ({ + params: { year: String(yearData.value) }, + })); +} + const { globals } = await fetchGlobalData(Astro); const books = await fetchBooks(); const { year } = Astro.params; @@ -45,7 +53,7 @@ const intro = isCurrentYear pageTitle={pageTitle} description={description} fullUrl={Astro.url.pathname} - ogImage={bookData[0].image} + ogImage={bookData[0]?.image || ""} > Back to books @@ -53,10 +61,5 @@ const intro = isCurrentYear

{year} / Books


- +