fix(registry): include unsuffixed logos in index, add logo SVG API - #48
Merged
Merged
Conversation
The logos index was built with `name.endsWith("-logo")`, which silently
excluded every logo whose item name carries no suffix. All 35 AWS service
logos (aws-s3, aws-lambda, ...) were published and reachable but invisible
to logos-index.json and therefore to @tryelements/cli.
Filter on the `logo` category instead, excluding bundle items under
_bundles/. Type is not a reliable discriminator here: 28 individual logos
(docker, figma, linear, resend, ...) are typed registry:block.
Index: 171 -> 206, matching the 206 logo directories on disk.
SVG generation:
- Derive the list from logos-index.json so it cannot drift from the index
- Resolve module-level constants, string arrays rendered via .map(), and
sub-components returning static JSX. amp, antigravity, codex and zep
previously emitted raw JSX
- Reject output containing unresolved expressions instead of writing a
broken file and counting it as a success
- Clear the output directory so removed logos leave no stale files, while
still writing the historical `<slug>-logo.svg` names that are already
published
All 377 emitted files validate as XML.
Add /api/logos returning a logo as svg, json (viewBox, paths, monochrome)
or dataurl, and /api/logos/all for the whole catalog in one request, so
non-React consumers do not have to parse the JSX component source.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
logos-index.jsonwas built withname.endsWith("-logo"). Every logo whose registry item name carries no suffix was skipped.All 35 AWS service logos (
aws-s3,aws-lambda, ...) were already published and reachable —/r/aws-s3.jsonreturns 200 today — but they were absent from the index, so@tryelements/cliand anyone discovering through the index could not see them.Fixing the filter surfaced 28 more individual logos (docker, figma, linear, resend, sentry, ...) that are typed
registry:blockrather thanregistry:ui, so type is not a usable discriminator either. The reliable signal is thelogocategory, excluding bundle items under_bundles/.Index: 171 -> 206, which matches the 206 logo directories on disk exactly.
SVG generation
generate-svg-files.tshad the same suffix assumption, plus three real defects:amp,antigravity,codexandzepemitted raw JSX (d={ICON_PATH},<GradientDef />). The script warned and wrote the file anyway. It now resolves module-level constants, string arrays rendered via.map(), and sub-components returning static JSX — and rejects anything still containing unresolved expressions instead of writing it.logos-index.json, so the SVGs cannot diverge from the index.All 377 emitted files validate as XML (
xmllint), with no empty shapes.Note the historical
<slug>-logo.svgnames are still written./r/svg/anthropic-logo.svgcurrently returns 200 in production, so dropping those paths would have broken live URLs.New API
The registry only ever served JSX, so any non-React consumer had to parse TypeScript to get a shape. That is why
@tryelements/cliexists — this moves that extraction server-side.CORS is open and responses are cached, so
<img src>and browser fetches work without a build step. Raster output is deliberately out of scope: it needs a rasterizer and per-request CPU, and SVG covers the cases we have.Verification
bun run typecheckandbun run buildboth pass