Skip to content

Serve the installs badges as JSON for shields.io too - #35

Merged
MCCProgrammer merged 1 commit into
mainfrom
feat/shields-badges
Oct 28, 2026
Merged

MCCProgrammer merged 1 commit into
mainfrom
feat/shields-badges

Conversation

@MCCProgrammer

Copy link
Copy Markdown
Owner

Why

vsce refuses SVG images in a README unless they come from a service it trusts ("SVGs are restricted in README.md"), and shields.io is one of them. An extension's README therefore can't point at /p/{slug}/.../badge.svg. It can use https://img.shields.io/endpoint?url=<our JSON>.

What

  • GET /p/{slug}/badge.json and GET /p/{slug}/extensions/{id}/badge.json return shields.io's endpoint schema, for example {"schemaVersion":1,"label":"installs","message":"12.3k","color":"256abf","cacheSeconds":3600}.
  • They are public, like the SVGs, and cached for an hour. An unknown address or another account's extension returns 404.
  • Badge.COLOR is shared by the SVG and the JSON, so both badges look the same.
  • The extension page in the dashboard now shows the shields.io README line under the SVG one.

Tests

  • PublicPagesTests: the JSON fields, the headers and the 404s.
  • DashboardPagesTests: both README lines appear once a public page exists.
  • ./mvnw verify passes: 181 tests.

The VS Code Marketplace only shows README badges from services it knows, so an
extension's README can't use this site's SVG. /p/{slug}/badge.json and
/p/{slug}/extensions/{id}/badge.json answer in shields.io's endpoint schema, and the
extension page gives the README line for both.
@sonarqubecloud

Copy link
Copy Markdown

@MCCProgrammer
MCCProgrammer merged commit a33f8fe into main Oct 28, 2026
10 checks passed
@MCCProgrammer
MCCProgrammer deleted the feat/shields-badges branch October 28, 2026 19:37
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.

1 participant