From edd3b0972115ebddd068ed226158ace07c706401 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 9 Aug 2026 19:32:06 -0400 Subject: feature: add a reading page --- src/pages/reading.astro | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/pages/reading.astro (limited to 'src/pages') diff --git a/src/pages/reading.astro b/src/pages/reading.astro new file mode 100644 index 0000000..0e1d1cb --- /dev/null +++ b/src/pages/reading.astro @@ -0,0 +1,60 @@ +--- +import { getCollection, type CollectionEntry } from "astro:content"; +import BaseLayout from "../layouts/BaseLayout.astro"; +import ReadingEntry from "../components/ReadingEntry.astro"; +import "../styles/post.css"; +import "../styles/sitemap.css"; + +type ReadingYear = CollectionEntry<"reading">; +type Entry = ReadingYear["data"]["entries"][number]; + +const years = await getCollection("reading"); +years.sort((a: ReadingYear, b: ReadingYear) => b.data.year - a.data.year); + +// Entries are authored oldest-first within a year; show the most recent first. +function newestFirst(entries: Entry[]): Entry[] { + return [...entries].reverse(); +} +--- + + +
+ { + years.map((year: ReadingYear) => { + const entries = newestFirst(year.data.entries); + const books = entries.filter((e: Entry) => e.type === "book"); + const articles = entries.filter( + (e: Entry) => e.type === "article", + ); + + return ( +
+

{year.data.year}

+ +
+
    + {books.map((entry: Entry) => ( + + ))} +
+ + {articles.length > 0 && ( + +

Articles

+
    + {articles.map((entry: Entry) => ( + + ))} +
+
+ )} +
+
+ ); + }) + } +
+
-- cgit v1.2.1