Skip to content

fix(www): fileName lookup in rehype-component's ComponentSource - #1025

Closed
zigzagdev wants to merge 1 commit into
magicuidesign:mainfrom
zigzagdev:fix/www-component-source-filename-lookup
Closed

zigzagdev wants to merge 1 commit into
magicuidesign:mainfrom
zigzagdev:fix/www-component-source-filename-lookup

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

The ComponentSource file lookup in rehype-component.ts only matched files entries that were plain strings, but every entry declared in registry-ui.ts / registry-examples.ts is an object ({ path, type, target }), so the fileName attribute was effectively ignored and the lookup always fell back to files[0]. Added a helper that reads the path from either shape and used it in the lookup.

Changes

  • Add a getFilePath() helper that reads the path from a files entry regardless of whether it's a plain string or an object ({ path, type, target })
  • Use it in ComponentSource's fileName search so it correctly matches against the object form (the shape actually used throughout the registry)

Motivation

The files.find() predicate only checked typeof file === "string", which is always false since every registry item declares its files as objects.
As a result, the fileName attribute on <ComponentSource name="..." fileName="..."> was silently ignored and the code always fell back to the first file.

Breaking Changes

None.

Screenshots

Not applicable.

Checklist

  • pnpm check — not run locally (dependencies not installed in this environment)
  • pnpm build — not run locally (dependencies not installed in this environment)
  • pnpm build:registry — not applicable
  • PR title follows Conventional Commits

component.files entries are objects like { path, type, target }, but
the fileName search only handled the case where a file entry was a
plain string, so the typeof file === "string" check was always false
and the find() always fell through to files[0] regardless of the
fileName attribute.

Add a getFilePath() helper that reads the path from either a string
or an object entry, and use it to find and resolve the matching file.
@zigzagdev zigzagdev changed the title fix(www): fix fileName lookup in rehype-component's ComponentSource fix(www): fileName lookup in rehype-component's ComponentSource Oct 12, 2026
@zigzagdev
zigzagdev marked this pull request as draft October 12, 2026 05:23
@Yeom-JinHo

Copy link
Copy Markdown
Member

@zigzagdev Thanks for the resubmission, but this is the same change as #1018. As noted there, rehypeComponent has been dead code since #807, and the file was removed in #1023 (merged yesterday), which is why this PR now conflicts with main. The fileName lookup no longer exists anywhere in the codebase, so there's nothing left to fix. Closing.

@Yeom-JinHo Yeom-JinHo closed this Oct 12, 2026
@zigzagdev
zigzagdev deleted the fix/www-component-source-filename-lookup branch October 12, 2026 22:30
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