Skip to content

feat(webui-press): normalize duplicate folder/filename paths as index#361

Open
mohamedmansour wants to merge 2 commits into
mainfrom
webui-press-normalize-index-paths
Open

feat(webui-press): normalize duplicate folder/filename paths as index#361
mohamedmansour wants to merge 2 commits into
mainfrom
webui-press-normalize-index-paths

Conversation

@mohamedmansour

Copy link
Copy Markdown
Contributor

Summary

Treat markdown files where the filename matches the parent folder name as index pages, avoiding redundant URL paths in the generated documentation.

Problem

Currently, a file like components/webui-button/webui-button.md generates the URL /webui-button/webui-button/, which has an unnecessary duplicate segment.

Solution

Added a normalize_path_as_index() helper function that:

  • Detects when a markdown filename matches its parent folder name
  • Strips the redundant filename segment
  • Treats the file as an index page for that folder

Examples

File Path Before After
webui-button/webui-button.md /webui-button/webui-button/ /webui-button/
webui-button/usage.md /webui-button/usage/ /webui-button/usage/ (unchanged)
components/webui-card/webui-card.md /components/webui-card/webui-card/ /components/webui-card/

Changes

  • normalize_path_as_index() - New helper function with clear documentation
  • build_page_registry() - Updated to normalize paths before URL generation
  • Tests - Added 6 comprehensive test cases covering:
    • Duplicate folder/filename normalization
    • Different filenames (no normalization)
    • Nested folder structures
    • Edge cases (no slash, deep nesting)

Testing

cargo test -p microsoft-webui-press normalize_path_as_index

All tests pass ✅

Impact

  • Breaking: URLs will change for files following the folder/folder.md pattern
  • Benefits: Cleaner, more intuitive URLs for component documentation
  • Compatibility: Sites using /index.md or different filenames are unaffected

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

mohamedmansour and others added 2 commits June 19, 2026 22:28
Treat markdown files where the filename matches the parent folder name as
index pages, avoiding redundant URL paths.

Example:
- Before: components/webui-button/webui-button.md → /webui-button/webui-button/
- After:  components/webui-button/webui-button.md → /webui-button/

This enables cleaner component documentation URLs while preserving support
for additional pages (e.g., webui-button/usage.md → /webui-button/usage).

Changes:
- Add normalize_path_as_index() helper to strip duplicate filenames
- Update build_page_registry() to normalize paths before URL generation
- Add comprehensive test coverage (6 test cases)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohamedmansour mohamedmansour requested review from a team, akroshg, janechu and mcritzjam June 20, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant