Skip to content

fix(ui): allow custom badge values in docs generator#2335

Merged
graphieros merged 2 commits intonpmx-dev:mainfrom
MathurAditya724:patch-6-issue-2326
Mar 30, 2026
Merged

fix(ui): allow custom badge values in docs generator#2335
graphieros merged 2 commits intonpmx-dev:mainfrom
MathurAditya724:patch-6-issue-2326

Conversation

@MathurAditya724
Copy link
Copy Markdown
Contributor

🔗 Linked issue

Closes #2326

🧭 Context

Custom badge value looked broken in docs because the value query param was not preserved through badge ISR route rules.

📚 Description

  • add value to badge route allowQuery in nuxt.config.ts
  • add an e2e test to verify ?value= is reflected in badge SVG output

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 30, 2026 6:05pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 30, 2026 6:05pm
npmx-lunaria Ignored Ignored Mar 30, 2026 6:05pm

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@MathurAditya724 MathurAditya724 marked this pull request as ready for review March 30, 2026 18:02
@MathurAditya724
Copy link
Copy Markdown
Contributor Author

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The pull request extends the ISR caching configuration for the badge API endpoint to include the 'value' query parameter in its variability list. The nuxt.config.ts file is updated to add 'value' to the allowQuery array for the /api/registry/badge/** route rule, enabling the caching layer to differentiate responses based on this parameter. A corresponding e2e test is added to validate that the 'value' query parameter is correctly processed and reflected in the generated badge SVG output.

Possibly related PRs

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description directly addresses the changeset: it explains the issue with the value query parameter, describes the fix (adding 'value' to allowQuery), and mentions the e2e test added.
Linked Issues check ✅ Passed The pull request successfully addresses the linked issue #2326 by adding the 'value' query parameter to the badge route's allowQuery configuration and verifying it works through an e2e test.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the custom badge value issue: updating the ISR route rule configuration and adding a corresponding e2e test. No unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@trueberryless trueberryless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Thanks for the investigation!
I completely missed that we have a whitelist for parameters. Well TIL! 🫡

Copy link
Copy Markdown
Contributor

@graphieros graphieros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌿

@graphieros graphieros added this pull request to the merge queue Mar 30, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/e2e/badge.spec.ts (1)

175-184: Strengthen this test to actually cover URL-encoded values.

custom-value-123 is not transformed by encodeURIComponent, so this currently validates plain value handling more than encoded value handling.

Proposed tweak
-  test('custom value parameter is applied to SVG', async ({ page, baseURL }) => {
-    const customValue = 'custom-value-123'
+  test('custom value parameter is applied to SVG', async ({ page, baseURL }) => {
+    const customValue = 'custom value 123'
     const url = toLocalUrl(
       baseURL,
       `/api/registry/badge/version/nuxt?value=${encodeURIComponent(customValue)}`,
     )
-    const { body } = await fetchBadge(page, url)
+    const { response, body } = await fetchBadge(page, url)
 
+    expect(response.status()).toBe(200)
     expect(body).toContain(customValue)
   })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf8379a0-9d7b-4f32-b3b3-3debbb6189ce

📥 Commits

Reviewing files that changed from the base of the PR and between b3da028 and 1c8e459.

📒 Files selected for processing (2)
  • nuxt.config.ts
  • test/e2e/badge.spec.ts

Merged via the queue into npmx-dev:main with commit 516808b Mar 30, 2026
20 checks passed
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
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.

Docs - Custom badge value not working

3 participants