Skip to content

Commit 494320a

Browse files
siriwatknpclaude
andcommitted
[docs] Fix pathname collision in LLMs docs generator
When multiple markdown files exist in the same directory, findPagesMarkdown() strips filenames causing pathname collisions. This resulted in the wrong file content being used (e.g., upgrade-to-v7.md incorrectly contained content from upgrade-to-native-color.md). Fix by matching files based on filename basename + parent path verification instead of relying solely on the stripped pathname. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6ee8cf1 commit 494320a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/buildLlmsDocs/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,14 @@ function findNonComponentMarkdownFiles(
264264
pathname.startsWith('/material-ui/') &&
265265
!ignoredPaths.some((ignored) => pathname.startsWith(ignored))
266266
) {
267-
const page = allMarkdownFiles.find((p) => p.pathname === parsedPathname);
267+
// Match by filename basename to avoid pathname collisions when multiple files
268+
// exist in the same directory (e.g., upgrade-to-v7.md and upgrade-to-native-color.md)
269+
const lastSegment = pathname.split('/').filter(Boolean).pop();
270+
const page = allMarkdownFiles.find((p) => {
271+
const fileBasename = path.basename(p.filename, '.md');
272+
const parentPath = parsedPathname.replace(/\/[^/]+$/, '');
273+
return fileBasename === lastSegment && p.filename.includes(parentPath);
274+
});
268275

269276
if (page) {
270277
files.push({

0 commit comments

Comments
 (0)