material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[docs] Fix pathname collision in LLMs docs generator

Open siriwatknp opened this issue 2 months ago • 1 comments

Root Cause

Before: https://mui.com/material-ui/migration/upgrade-to-v7.md (show native color content which is wrong)

The findNonComponentMarkdownFiles() function uses findPagesMarkdown() which strips the filename from the path to create a "pathname". When multiple markdown files exist in the same directory, they produce identical pathnames:

docs/data/material/migration/upgrade-to-v7/
├── upgrade-to-v7.md          → pathname: /material/migration/upgrade-to-v7
└── upgrade-to-native-color.md → pathname: /material/migration/upgrade-to-v7  (collision!)

The find() method then returns the first alphabetically ordered file (upgrade-to-native-color.md), causing upgrade-to-v7.md to be generated with the wrong content.

Solution

Updated the file matching logic to use:

  1. Filename basename match - Compare the actual filename (e.g., upgrade-to-v7)
  2. Parent path verification - Ensure the file is in the expected directory

This prevents collisions while maintaining compatibility with the existing file structure.

Testing

Verified all 13 migration files generate with correct content:

  • upgrade-to-v7.md → "Upgrade to v7" content
  • upgrade-to-native-color.md → "Upgrade to native color" content

siriwatknp avatar Nov 07 '25 15:11 siriwatknp

Netlify deploy preview

https://deploy-preview-47209--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by :no_entry_sign: dangerJS against dd8c366e2c17574dbf41e91aaa98c35bfbd28051

mui-bot avatar Nov 07 '25 15:11 mui-bot