feat: source sidebar quotes from a local dataset #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/local-quotes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
src/data/quotes.json— 440 programming quotes ({ quote, author }, every quote < 220 chars, the same length filter the old API applied), extracted from the upstreammudroljub/programming-quotes-api.src/lib/quote.tsto a synchronousgetQuote()returning a random entry. Removes thefetch, the module-level cache, the SVG regex scraping, and theconsole.logcalls.src/components/Sidebar.astroto dropawait.Net effect: no network call at build time, and a fresh random quote per page.
Testing
src/lib/quote.test.ts(random→index mapping, dataset membership, and a data-invariant guard that every entry is non-empty and < 220 chars).