Skip to content

Conversation

@siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Nov 7, 2025

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

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>
@siriwatknp siriwatknp requested a review from Janpot November 7, 2025 15:08
@siriwatknp siriwatknp added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Nov 7, 2025
@mui-bot
Copy link

mui-bot commented Nov 7, 2025

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 🚫 dangerJS against dd8c366

@Janpot Janpot requested a review from Copilot November 7, 2025 16:22
Copy link

Copilot AI left a 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.

siriwatknp and others added 6 commits November 10, 2025 08:46
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>
@siriwatknp siriwatknp merged commit 57bd892 into mui:master Nov 13, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants