Skip to content

fix(theme): bundle code snippet language icons locally - #1595

Merged
sserrata merged 5 commits into
mainfrom
fix/bundle-code-snippet-icons
Aug 11, 2026
Merged

sserrata merged 5 commits into
mainfrom
fix/bundle-code-snippet-icons

Conversation

@sserrata

Copy link
Copy Markdown
Member

Problem

Code snippet language icons stopped rendering even though fetching the SVGs returns HTTP 200.

The icons in the code snippet tabs were hot-linked from raw.githubusercontent.com (the devicons/devicon repo) via CSS background: url(). GitHub serves raw .svg files with:

  • Content-Type: text/plain (not image/svg+xml)
  • X-Content-Type-Options: nosniff

So the browser downloads each file successfully (200) but nosniff forbids treating a text/plain response as an image — the icon is silently dropped. This is long-standing GitHub behavior, not a recent GitHub change; the failure surfaced independent of any code change here.

Fix

  • Vendor the 18 language SVGs into packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/icons/ (from devicon v2.17.0, MIT).
  • Repoint all 18 background: url(...) refs in _CodeTabs.scss from raw.githubusercontent.com to local ./icons/<lang>.svg.
  • Add icons/README.md documenting source, license, and rationale.

Icon rendering no longer depends on GitHub's raw-content headers or network access. The http and shell tabs were already inline data URIs and are untouched.

Verification

  • No raw.githubusercontent refs remain in the SCSS.
  • yarn build passes; the copy step ships all 18 SVGs and the SCSS into lib/, so url("./icons/*.svg") resolves through the consumer's css-loader at build time.

🤖 Generated with Claude Code

sserrata and others added 2 commits August 10, 2026 16:59
The language icons in the code snippet tabs were hot-linked from
raw.githubusercontent.com (devicons/devicon). GitHub serves raw .svg
files as `text/plain` with `X-Content-Type-Options: nosniff`, so browsers
download them (HTTP 200) but refuse to render them as images via CSS
`background: url()`. The icons silently stopped rendering.

Vendor the 18 SVGs into the theme package and repoint the SCSS at local
relative paths so icon rendering no longer depends on GitHub's raw-content
headers or network access. Icons are from devicon v2.17.0 (MIT).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Relative url("./icons/*.svg") in a SCSS partial fails to resolve under
rspack (Docusaurus Faster) because url() is resolved relative to the entry
styles.scss, not the partial — CI failed with
RspackResolver(NotFound("./icons/python.svg")).

Inline the 18 icons as base64 SVG data URIs (matching the existing http and
shell tabs). Self-contained, bundler-agnostic, no network dependency.
Icons vendored from devicon v2.17.0 (MIT). Remove the now-unused icons/ dir.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Size Change: +44.8 kB (+1.9%)

Total Size: 2.4 MB

📦 View Changed
Filename Size Change
demo/build/assets/css/styles.********.css 218 kB +44.8 kB (+25.88%) 🚨
ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 16.4 kB
demo/.docusaurus/globalData.json 83 kB
demo/.docusaurus/i18n.json 372 B
demo/.docusaurus/registry.js 120 kB
demo/.docusaurus/routes.js 114 kB
demo/.docusaurus/routesChunkNames.json 47.2 kB
demo/.docusaurus/site-metadata.json 1.58 kB
demo/build/assets/js/main.********.js 700 kB
demo/build/assets/js/runtime~main.********.js 27.1 kB
demo/build/index.html 99.4 kB
demo/build/petstore/add-pet/index.html 29.5 kB
demo/build/petstore/create-user/index.html 24.2 kB
demo/build/petstore/create-users-with-array-input/index.html 24.3 kB
demo/build/petstore/create-users-with-list-input/index.html 24.3 kB
demo/build/petstore/delete-order/index.html 24.1 kB
demo/build/petstore/delete-pet/index.html 24.3 kB
demo/build/petstore/delete-user/index.html 24.5 kB
demo/build/petstore/find-pets-by-status/index.html 25 kB
demo/build/petstore/find-pets-by-tags/index.html 25.7 kB
demo/build/petstore/get-inventory/index.html 23.4 kB
demo/build/petstore/get-order-by-id/index.html 24.4 kB
demo/build/petstore/get-pet-by-id/index.html 25.1 kB
demo/build/petstore/get-user-by-name/index.html 24.6 kB
demo/build/petstore/login-user/index.html 25.1 kB
demo/build/petstore/logout-user/index.html 23.9 kB
demo/build/petstore/new-pet/index.html 24.5 kB
demo/build/petstore/pet/index.html 22.8 kB
demo/build/petstore/place-order/index.html 23.6 kB
demo/build/petstore/schemas/apiresponse/index.html 24.9 kB
demo/build/petstore/schemas/cat/index.html 38.9 kB
demo/build/petstore/schemas/category/index.html 26 kB
demo/build/petstore/schemas/dog/index.html 39.2 kB
demo/build/petstore/schemas/honeybee/index.html 39.3 kB
demo/build/petstore/schemas/id/index.html 23.1 kB
demo/build/petstore/schemas/order/index.html 27.1 kB
demo/build/petstore/schemas/pet/index.html 38.9 kB
demo/build/petstore/schemas/tag/index.html 24.4 kB
demo/build/petstore/schemas/user/index.html 40.8 kB
demo/build/petstore/store/index.html 21.8 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 30.5 kB
demo/build/petstore/swagger-petstore-yaml/index.html 30.7 kB
demo/build/petstore/update-pet-with-form/index.html 24.5 kB
demo/build/petstore/update-pet/index.html 24.9 kB
demo/build/petstore/update-user/index.html 24.5 kB
demo/build/petstore/upload-file/index.html 24.4 kB
demo/build/petstore/user/index.html 22.4 kB

compressed-size-action

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 9160560):

https://docusaurus-openapi-36b86--pr1595-ovd9z8es.web.app

(expires Tue, 18 Aug 2026 13:25:26 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

📸 Visual Diff Report

Snapshot comparison against https://docusaurus-openapi.tryingpan.dev/

Total ✅ Match ❌ Diff ⏭ Skip
228 154 74 0
❌ 74 page(s) with visual regressions

/tests/all-of-inherits-parent-required

Prod Preview Diff
prod screenshot for /tests/all-of-inherits-parent-required preview screenshot for /tests/all-of-inherits-parent-required pixel diff for /tests/all-of-inherits-parent-required

/tests/all-of-override-of-nested-array-items-with-one-of

Prod Preview Diff
prod screenshot for /tests/all-of-override-of-nested-array-items-with-one-of preview screenshot for /tests/all-of-override-of-nested-array-items-with-one-of pixel diff for /tests/all-of-override-of-nested-array-items-with-one-of

/tests/all-of-with-additional-properties-false-on-every-member

Prod Preview Diff
prod screenshot for /tests/all-of-with-additional-properties-false-on-every-member preview screenshot for /tests/all-of-with-additional-properties-false-on-every-member pixel diff for /tests/all-of-with-additional-properties-false-on-every-member

/tests/all-of-with-deep-merging

Prod Preview Diff
prod screenshot for /tests/all-of-with-deep-merging preview screenshot for /tests/all-of-with-deep-merging pixel diff for /tests/all-of-with-deep-merging

/tests/all-of-with-explicit-empty-object-properties

Prod Preview Diff
prod screenshot for /tests/all-of-with-explicit-empty-object-properties preview screenshot for /tests/all-of-with-explicit-empty-object-properties pixel diff for /tests/all-of-with-explicit-empty-object-properties

/tests/all-of-with-enum-parameter

Prod Preview Diff
prod screenshot for /tests/all-of-with-enum-parameter preview screenshot for /tests/all-of-with-enum-parameter pixel diff for /tests/all-of-with-enum-parameter

/tests/all-of-with-array-items

Prod Preview Diff
prod screenshot for /tests/all-of-with-array-items preview screenshot for /tests/all-of-with-array-items pixel diff for /tests/all-of-with-array-items

/tests/all-of-with-incompatible-types

Prod Preview Diff
prod screenshot for /tests/all-of-with-incompatible-types preview screenshot for /tests/all-of-with-incompatible-types pixel diff for /tests/all-of-with-incompatible-types

/tests/all-of-with-nested-all-of

Prod Preview Diff
prod screenshot for /tests/all-of-with-nested-all-of preview screenshot for /tests/all-of-with-nested-all-of pixel diff for /tests/all-of-with-nested-all-of

/tests/all-of-with-properties-in-array-item

Prod Preview Diff
prod screenshot for /tests/all-of-with-properties-in-array-item preview screenshot for /tests/all-of-with-properties-in-array-item pixel diff for /tests/all-of-with-properties-in-array-item

/tests/all-of-with-same-level-properties

Prod Preview Diff
prod screenshot for /tests/all-of-with-same-level-properties preview screenshot for /tests/all-of-with-same-level-properties pixel diff for /tests/all-of-with-same-level-properties

/tests/all-of-with-shared-required-properties

Prod Preview Diff
prod screenshot for /tests/all-of-with-shared-required-properties preview screenshot for /tests/all-of-with-shared-required-properties pixel diff for /tests/all-of-with-shared-required-properties

/tests/control-no-x-code-samples

Prod Preview Diff
prod screenshot for /tests/control-no-x-code-samples preview screenshot for /tests/control-no-x-code-samples pixel diff for /tests/control-no-x-code-samples

/tests/cookie-parameter-default

Prod Preview Diff
prod screenshot for /tests/cookie-parameter-default preview screenshot for /tests/cookie-parameter-default pixel diff for /tests/cookie-parameter-default

/tests/create-user-nested-request-body

Prod Preview Diff
prod screenshot for /tests/create-user-nested-request-body preview screenshot for /tests/create-user-nested-request-body pixel diff for /tests/create-user-nested-request-body

/tests/custom-verb-endpoint-in-path

Prod Preview Diff
prod screenshot for /tests/custom-verb-endpoint-in-path preview screenshot for /tests/custom-verb-endpoint-in-path pixel diff for /tests/custom-verb-endpoint-in-path

/tests/duplicate-lang-label-defensive-collision-suffix

Prod Preview Diff
prod screenshot for /tests/duplicate-lang-label-defensive-collision-suffix preview screenshot for /tests/duplicate-lang-label-defensive-collision-suffix pixel diff for /tests/duplicate-lang-label-defensive-collision-suffix

/tests/example-in-request-parameters-schema

Prod Preview Diff
prod screenshot for /tests/example-in-request-parameters-schema preview screenshot for /tests/example-in-request-parameters-schema pixel diff for /tests/example-in-request-parameters-schema

/tests/example-in-request-parameters

Prod Preview Diff
prod screenshot for /tests/example-in-request-parameters preview screenshot for /tests/example-in-request-parameters pixel diff for /tests/example-in-request-parameters

/tests/example-of-media-type-object-in-response

Prod Preview Diff
prod screenshot for /tests/example-of-media-type-object-in-response preview screenshot for /tests/example-of-media-type-object-in-response pixel diff for /tests/example-of-media-type-object-in-response

/tests/example-of-media-type-object-in-request-body

Prod Preview Diff
prod screenshot for /tests/example-of-media-type-object-in-request-body preview screenshot for /tests/example-of-media-type-object-in-request-body pixel diff for /tests/example-of-media-type-object-in-request-body

/tests/example-of-schema-in-request-body

Prod Preview Diff
prod screenshot for /tests/example-of-schema-in-request-body preview screenshot for /tests/example-of-schema-in-request-body pixel diff for /tests/example-of-schema-in-request-body

/tests/example-of-properties-in-request-body-schema

Prod Preview Diff
prod screenshot for /tests/example-of-properties-in-request-body-schema preview screenshot for /tests/example-of-properties-in-request-body-schema pixel diff for /tests/example-of-properties-in-request-body-schema

/tests/example-of-schema-in-response

Prod Preview Diff
prod screenshot for /tests/example-of-schema-in-response preview screenshot for /tests/example-of-schema-in-response pixel diff for /tests/example-of-schema-in-response

/tests/example-of-schema-properties-in-response

Prod Preview Diff
prod screenshot for /tests/example-of-schema-properties-in-response preview screenshot for /tests/example-of-schema-properties-in-response pixel diff for /tests/example-of-schema-properties-in-response

… and 49 more page(s) with regressions. See the HTML report for the full list.

Updated at 2026-08-11T13:32:22.854Z · run 31495769843

The inlined devicon SVGs have a viewBox but no intrinsic width/height, so
without background-size the icons rendered inconsistently. Match the http/shell
icons which already set background-size: contain.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Literal non-ASCII glyphs made dart-sass prepend a UTF-8 BOM to the compiled
stylesheet. Mid-bundle that BOM invalidated the following :root selector,
dropping --code-tab-logo-width/height so code-tab icons rendered at 0x0.
Emit the glyphs as ASCII CSS escapes via string.unquote to keep output
BOM-free.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@sserrata
sserrata merged commit 12ce651 into main Aug 11, 2026
12 checks passed
@sserrata
sserrata deleted the fix/bundle-code-snippet-icons branch August 11, 2026 15:06
@sserrata sserrata mentioned this pull request Aug 11, 2026
4 tasks done

This branch was previously deployed

1 inactive deployment
preview — 9160560e Deployed Aug 11, 2026 by sserrata via Visual Diff #2326
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