[docs] Fix pathname collision in LLMs docs generator#47209
Merged
siriwatknp merged 7 commits intomui:masterfrom Nov 13, 2025
Merged
[docs] Fix pathname collision in LLMs docs generator#47209siriwatknp merged 7 commits intomui:masterfrom
siriwatknp merged 7 commits intomui:masterfrom
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
|
Contributor
There was a problem hiding this comment.
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>
Janpot
approved these changes
Nov 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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