Skip to content

feat(icon): let consumers rewrite icon URLs with IconUrlContext - #267

Merged
N43527 merged 1 commit into
mainfrom
nivedh/icon-url-context
Oct 22, 2026
Merged

N43527 merged 1 commit into
mainfrom
nivedh/icon-url-context

Conversation

@N43527

@N43527 N43527 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Icon and LanguageIcon always point at the icons CDN. mint export needs to load them from the exported bundle instead (air-gapped sites, strict CSP), but there was no way to change the URL, including for icons drawn inside other components like Expandable.

Adds IconUrlContext, a function that receives the icon URL and returns the one to render. The default returns it unchanged, so existing consumers see no difference.

Test plan

  • pnpm build, pnpm lint:check
  • Packed this build into mint with its export wired to the context (mint PR to follow). Exported mintlify/docs and loaded API reference pages in Chrome with all external requests blocked: 0 icon requests to the CDN (before: play and arrow icons on 96 pages), icons render from the bundle, 0 page errors.

Note

Low Risk
Additive API with identity default; only affects how icon mask URLs are computed when a provider overrides them.

Overview
Introduces IconUrlContext, a React context whose value is an (url) => string resolver (default: identity), exported from the icon package so hosts like mint export can remap CDN icon URLs to local bundle paths for air-gapped or strict-CSP sites.

Icon and LanguageIcon now run every CDN/mask icon URL through that resolver before setting maskImage / WebkitMaskImage, including Mintlify CDN absolute icon strings. Behavior is unchanged when no provider is supplied.

Reviewed by Cursor Bugbot for commit b9be99b. Bugbot is set up for automated code reviews on this repo. Configure here.

@N43527
N43527 marked this pull request as ready for review October 22, 2026 22:38

type IconUrlResolver = (url: string) => string;

const IconUrlContext = createContext<IconUrlResolver>((url) => url);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Means if no one using this has said anything different, then reuse the same functionality

(that way only mint export will be updated to have this fix)

@N43527
N43527 merged commit 16475bb into main Oct 22, 2026
3 checks passed
@N43527 N43527 mentioned this pull request Oct 23, 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.

2 participants