Skip to content

refactor: migrate sponsors banner to component with caching, for #363 #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025

Conversation

stasadev
Copy link
Member

@stasadev stasadev commented May 8, 2025

The Issue

The sponsors banner has a few problems:

Sponsorship data isn't cached, and there’s no fallback if GitHub is unavailable:

image

Pressing F5 or moving from page to page causes the whole site to jump:

jump

How This PR Solves The Issue

  1. Adds initial cache for all sponsorships during npm run build (so GitHub failure doesn't break it) and then caches fresh data for a day.

  2. I tried several ways to make the banner appear immediately. Nothing worked, I asked ChatGPT to refactor it into an Astro component, which stopped the jumping. This was annoying.

Manual Testing Instructions

  1. Open https://20250508-stasadev-sponsors-b.ddev-com-front-end.pages.dev/
  2. Check that it doesn't jump
  3. Open Dev panel (F12)
  4. Check network tab for Fetch/XHR requests, it should fetch from GitHub only the first time
  5. Check application tab for ddevSponsorshipData in local storage
  6. Delete ddevSponsorshipData, open network tab again, and check for new fetch from GitHub

Note: I deleted src/scripts/sponsors-banner.js as not needed.

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@rfay
Copy link
Member

rfay commented May 8, 2025

Thanks!

@stasadev stasadev changed the title refactor: migrate sponsors banner to component with caching refactor: migrate sponsors banner to component with caching, for #363 May 8, 2025
@stasadev stasadev merged commit b415a60 into main May 8, 2025
2 checks passed
@stasadev stasadev deleted the 20250508_stasadev_sponsors_banner branch May 8, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants