feat(api): add compact=true param for slim single-row streak card#6130
Conversation
Adds a compact query param to /api/streak that renders a 280x100 single-row SVG with username and current streak count, skipping the full isometric grid. Reuses existing theme/font/color sanitization so bg, accent, text, and font params apply consistently with the full card. Closes JhaSourav07#5724
|
@vbarik317-droid is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Fix: streakParamsSchema already validated year correctly, but the route wasn't using the parsed value — it fell back to raw searchParams.get('year') for the date math, so invalid years slipped through. Now using the validated value consistently. Added a route-level test for year=2099 → 400. |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod-Dev
left a comment
There was a problem hiding this comment.
This is a great feature! The compact=true parameter gives users much-needed flexibility for integrating the streak card in tighter layouts like repository README sidebars. Bypassing the expensive isometric tower computation in generateSVG when params.compact is true is also a smart performance optimization. Approved!
|
🎉 Congratulations @vbarik317-droid! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
Closes #5724.
Summary
Adds a
compact=truequery param to/api/streakthat renders a slim, single-row version of the streak card (280×100px) instead of the full 3D isometric grid. Useful for narrow README layouts and sidebar badges.Changes
types/index.ts: addedcompact?: booleantoBadgeParamsapp/api/streak/route.ts: parsescompactfrom the query string and passes it through to the badge paramslib/svg/generator.ts: addedgenerateCompactSVG()and branchedgenerateSVG()to call it early whenparams.compactis true, before the expensive tower computation runsBehavior
compact=true→ renders username + 🔥 current streak count in a slim card, no isometric towerscompactomitted → full isometric card renders unchanged (no regression)bg,accent,text, andfontparams are sanitized and applied the same way as the full card, so theming stays consistentTesting
Tested locally with
npm run dev+ curl:/api/streak?user=octocat&compact=true→ 280×100 slim card/api/streak?user=octocat→ unchanged 600×420 full card/api/streak?user=octocat&compact=true&bg=1a1a2e&accent=ff6b35&text=eaeaea→ theme overrides apply correctlyChecklist
compact=truetriggers slim card rendercompactis omitted