Skip to content

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

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

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

Conversation

@zigzagdev

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

Device / Browser / Viewport:

Before After

N/A

Checklist

  • pnpm check passes locally
  • pnpm build passes locally
  • pnpm build:registry was run and the generated files are committed (if you changed registry/ or config/site.ts — CI verifies this on every PR)
  • PR title follows Conventional Commits (e.g., feat(marquee): add reverse prop)

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.
@vercel

vercel Bot commented Oct 7, 2026

Copy link
Copy Markdown

@zigzagdev is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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