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


- +