From 789583142c61cc82291104b6ea14e4dd097d4ecf Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 21 May 2025 00:45:20 +0200 Subject: [PATCH] feat: add books page with filtering and create sample book content --- content/books/my-first-book copy.md | 2 +- src/pages/books.astro | 51 ++++++++++++++++++----------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/content/books/my-first-book copy.md b/content/books/my-first-book copy.md index 8b4ed59..06a1ac0 100644 --- a/content/books/my-first-book copy.md +++ b/content/books/my-first-book copy.md @@ -3,7 +3,7 @@ title: "Dune 2" year: 1966 media_type: "book" genre: "Brol" -rating: 5 +rating: 1 cover: "/covers/dune-placeholder.jpg" status: "Read" date_added: "2025-05-20" diff --git a/src/pages/books.astro b/src/pages/books.astro index 6d24976..7dfb487 100644 --- a/src/pages/books.astro +++ b/src/pages/books.astro @@ -82,18 +82,32 @@ const alpineData = { {booksFoundCount > 0 ? (
- {allBooksAstro.map(book => ( -
{/* fallback to show all if Alpine not ready */} - +
) : (
@@ -136,15 +150,12 @@ const alpineData = { let ratingMatch = this.selectedRating === '' || (ratingValue !== undefined && ratingValue !== null && ratingValue >= selectedRatingValue); - // Temporary debug log for rating filter - if (this.selectedRating !== '') { - console.log( - `Book: "${book.title}", Book Rating: ${ratingValue} (type: ${typeof ratingValue}), ` + - `Selected Dropdown Rating: "${this.selectedRating}" (type: ${typeof this.selectedRating}), ` + - `Parsed Selected: ${selectedRatingValue} (type: ${typeof selectedRatingValue}), Match: ${ratingMatch}` - ); - } - return genreMatch && ratingMatch; + // Debug log for genre and rating filter + console.log( + `Book: "${book.title}", Book Genre: "${book.genre}", Selected Genre: "${this.selectedGenre}", Genre Match: ${genreMatch}, ` + + `Book Rating: ${ratingValue} (type: ${typeof ratingValue}), Selected Dropdown Rating: "${this.selectedRating}" (type: ${typeof this.selectedRating}), Parsed Selected: ${selectedRatingValue} (type: ${typeof selectedRatingValue}), Rating Match: ${ratingMatch}` + ); + return genreMatch && ratingMatch; }); },