Skip to content

fix(migrate): keep MkDocs nav to the nav block - #285

Merged
mgks merged 1 commit into
docmd-io:mainfrom
jayhemnani9910:fix/mkdocs-migrate-nav
Nov 16, 2026
Merged

mgks merged 1 commit into
docmd-io:mainfrom
jayhemnani9910:fix/mkdocs-migrate-nav

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Description

docmd migrate --mkdocs builds a broken sidebar from a typical mkdocs.yml:

nav:
  - Home: index.md
  - Guide:
    - Overview: guide/index.md
    - Setup: guide/setup.md
  - 'Change Log': changelog.md
plugins:
  - search
  - tags
markdown_extensions:
  - admonition
  - toc:
      permalink: true

Before:

  • Home links to index/ and Overview to guide/index/. docmd build does not generate those pages (index.md is served at its folder), so both links 404.
  • search, tags, admonition and toc show up as sidebar entries: parseMkDocsNav reads to the end of the file, so every - item under plugins: and markdown_extensions: is added.
  • 'Change Log' keeps its quotes in the title (and a quoted file keeps them in the path).

After: Home /, Overview guide/, Setup guide/setup/, Change Log → changelog/, nothing else. The nav now stops at the next top-level key, index.md maps to its folder (/ for the root), and one level of matching quotes is removed.

The N-9 check in migrate.test.js looked for index in the generated nav, which matched the old index/ path; it now expects the Home path /.

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Added a case to tests/cli-contracts/migrate.test.js with the config above; it fails without the change. node tests/runner.js: 1419 passed; the one failure (Dev --host flag, ENOSPC on file watchers) fails the same way on main here. pnpm lint: no errors. Migrated and built the example above: the sidebar links resolve.

parseMkDocsNav read to the end of mkdocs.yml, so every item under plugins: and markdown_extensions: became a sidebar entry. index.md pages were linked as index/ (not generated, 404), and quoted titles and paths kept their quotes. Stop at the next top-level key, map index.md to its folder ('/' for the root) and drop the quotes. The N-9 check now expects the Home path '/' instead of index/.
@mgks

mgks commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Merged and available in v0.10.1.

This properly bounds parseMkDocsNav to the nav: block, strips outer quotation marks, and cleanly resolves index.md files to / or their parent folder routes.

Thank you @jayhemnani9910 for the clean fix and test coverage!

@mgks mgks closed this Nov 16, 2026
@mgks mgks reopened this Nov 16, 2026
@mgks
mgks merged commit 68fe3f9 into docmd-io:main Nov 16, 2026
1 check passed
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.

2 participants