Skip to content

feat(themes): add random theme selection via ?theme=random#115

Open
Subhooo5 wants to merge 1 commit into
JhaSourav07:mainfrom
Subhooo5:feat/random-theme-support
Open

feat(themes): add random theme selection via ?theme=random#115
Subhooo5 wants to merge 1 commit into
JhaSourav07:mainfrom
Subhooo5:feat/random-theme-support

Conversation

@Subhooo5
Copy link
Copy Markdown

@Subhooo5 Subhooo5 commented May 16, 2026

Description

Fixes #66

Adds support for ?theme=random as a valid theme value on the /api/streak endpoint. When passed, the API dynamically picks a random theme from the available themes object on every request, giving users a surprise theme on every load.

  • Changes made in app/api/streak/route.ts:
    Added an isRandomTheme flag that checks if theme === 'random'. If true, a random key is picked from the themes object using Math.random(), with a || themes.dark fallback to ensure no crash if the selection somehow fails.

  • Also extended the cacheControl condition to disable caching when isRandomTheme is true:
    const cacheControl = refresh || isRandomTheme
    ? 'no-cache, no-store, must-revalidate'
    : public, s-maxage=${secondsToMidnight}, stale-while-revalidate=86400;

    Without this, the CDN would cache the first random SVG and serve the same theme to all users for hours, defeating the purpose of the feature entirely.

  • Changes made in README.md:
    Added random to the Theme Presets table with varies for all color columns since the values change dynamically on every load.

No other files were modified.

Pillar

  • 🛠️ Other (Bug fix, refactoring, docs)

Working Video

https://collection.cloudinary.com/dqvm8dce2/73286b27f012f3021856fee1142847bf

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME&theme=random).
  • I have run npm run format and npm run lint locally and resolved all errors.
  • My commits follow the Conventional Commits format.
  • I have updated README.md added a new 'random' theme preset.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 16, 2026

@Subhooo5 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Subhooo5 Subhooo5 force-pushed the feat/random-theme-support branch from 5b1dbcc to bf1a564 Compare May 16, 2026 11:11
@Subhooo5
Copy link
Copy Markdown
Author

Subhooo5 commented May 16, 2026

Hey @JhaSourav07 , please feel free to review the PR and merge the same. It satisfies all the acceptance criteria. Thank you 🚀🫂. Looking forward to solving several more issues/bugs and adding enhancements/features throughout the GSSoC journey🥰.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commitpulse Ready Ready Preview, Comment May 16, 2026 11:39am

@JhaSourav07
Copy link
Copy Markdown
Owner

@Subhooo5

can you attach a video of working?

@JhaSourav07 JhaSourav07 added GSSoC 2026 level:intermediate Moderate complexity tasks quality:exceptional Outstanding contribution with exceptional implementation quality, testing. backend Server-side logic, API routes, data fetching, and core application functionality labels May 16, 2026
@JhaSourav07
Copy link
Copy Markdown
Owner

@harxhe

can you review this PR?

@Subhooo5
Copy link
Copy Markdown
Author

@Subhooo5

can you attach a video of working?

Done 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side logic, API routes, data fetching, and core application functionality GSSoC 2026 level:intermediate Moderate complexity tasks mentor:harxhe quality:exceptional Outstanding contribution with exceptional implementation quality, testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Support "random" theme parameter for SVG generation

2 participants