feat: source sidebar quotes from a local dataset #4

Merged
fiatcode merged 2 commits from feat/local-quotes into main 2026-06-18 17:50:07 +07:00
Owner

What

Replaces the external quote-fetch with a locally bundled dataset.

The sidebar "fortune" quote was fetched at build time from a third-party Vercel API (quotes-github-readme.vercel.app), whose SVG output was regex-scraped for the quote and author. This coupled every build to that service staying up and its markup not changing.

Changes

  • Add src/data/quotes.json — 440 programming quotes ({ quote, author }, every quote < 220 chars, the same length filter the old API applied), extracted from the upstream mudroljub/programming-quotes-api.
  • Rewrite src/lib/quote.ts to a synchronous getQuote() returning a random entry. Removes the fetch, the module-level cache, the SVG regex scraping, and the console.log calls.
  • Update src/components/Sidebar.astro to drop await.

Net effect: no network call at build time, and a fresh random quote per page.

Testing

  • TDD: 5 new tests in src/lib/quote.test.ts (random→index mapping, dataset membership, and a data-invariant guard that every entry is non-empty and < 220 chars).
  • Full suite: 94/94 passing. Build clean (48 pages).
## What Replaces the external quote-fetch with a locally bundled dataset. The sidebar "fortune" quote was fetched at build time from a third-party Vercel API (`quotes-github-readme.vercel.app`), whose SVG output was regex-scraped for the quote and author. This coupled every build to that service staying up and its markup not changing. ## Changes - Add `src/data/quotes.json` — 440 programming quotes (`{ quote, author }`, every quote < 220 chars, the same length filter the old API applied), extracted from the upstream `mudroljub/programming-quotes-api`. - Rewrite `src/lib/quote.ts` to a synchronous `getQuote()` returning a random entry. Removes the `fetch`, the module-level cache, the SVG regex scraping, and the `console.log` calls. - Update `src/components/Sidebar.astro` to drop `await`. Net effect: no network call at build time, and a fresh random quote per page. ## Testing - TDD: 5 new tests in `src/lib/quote.test.ts` (random→index mapping, dataset membership, and a data-invariant guard that every entry is non-empty and < 220 chars). - Full suite: 94/94 passing. Build clean (48 pages).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fiatcode/site!4
No description provided.