-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[docs] Fix pathname collision in LLMs docs generator #47209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
Netlify deploy previewhttps://deploy-preview-47209--material-ui.netlify.app/ Bundle size report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the file matching logic in the findNonComponentMarkdownFiles function to fix pathname collision issues when multiple markdown files exist in the same directory.
Key Changes:
- Replaced simple pathname equality check with a more sophisticated matching algorithm that compares file basenames and verifies parent directory paths
- Added logic to extract the last segment from pathnames and match against actual file basenames
- Introduced parent path verification to ensure files are located in the correct directory structure
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Siriwat K <siriwatkunaporn@gmail.com>
The previous fix compared path.dirname(p.filename) (filesystem path like
"docs/data/material/migration/upgrade-to-v7") with parsedPathname
("/material/migration"). These never match.
The correct approach is to use p.pathname which findPagesMarkdown already
sets to the URL path with the filename stripped (e.g., "/material/migration/upgrade-to-v7").
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Root Cause
Before: https://mui.com/material-ui/migration/upgrade-to-v7.md (show native color content which is wrong)
The
findNonComponentMarkdownFiles()function usesfindPagesMarkdown()which strips the filename from the path to create a "pathname". When multiple markdown files exist in the same directory, they produce identical pathnames:The
find()method then returns the first alphabetically ordered file (upgrade-to-native-color.md), causingupgrade-to-v7.mdto be generated with the wrong content.Solution
Updated the file matching logic to use:
upgrade-to-v7)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" contentupgrade-to-native-color.md→ "Upgrade to native color" content