Skip to content

Commit 57bd892

Browse files
authored
[docs] Fix pathname collision in LLMs docs generator (#47209)
1 parent 37ad579 commit 57bd892

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).replace(/\.mdx?$/, '');
272+
// p.pathname already has the parent path (from findPagesMarkdown which strips the filename)
273+
return fileBasename === lastSegment && p.pathname === parsedPathname;
274+
});
268275

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

0 commit comments

Comments
 (0)