Skip to content

fix(parser): resolve folder-index links from nested pages - #271

Merged
mgks merged 1 commit into
docmd-io:mainfrom
GPT-AGI:fix/non-index-folder-links
Nov 11, 2026
Merged

mgks merged 1 commit into
docmd-io:mainfrom
GPT-AGI:fix/non-index-folder-links

Conversation

@GPT-AGI

@GPT-AGI GPT-AGI commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Description

A non-index page is emitted as <slug>/index.html, one directory deeper than the markdown file. Relative links get an extra ../ so they still resolve. index.md and README.md normalise to an empty path (the current directory) and that case skipped the shift.

From docs/guide.md (output docs/guide/index.html):

source before after
[Overview](index.md) href="" href="../"
[Setup](index.md#setup) href="#setup" href="../#setup"
[Readme](README.md) href="" href="../"
[Sibling](other.md) href="../other/" unchanged
[Here](#local) href="#local" unchanged

On an index page, [Setup](index.md#setup) stays href="#setup". Buttons use the same shift (::: button "Home" url:index.md).

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

Fixes # n/a

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

No user-facing docs page describes this shift. The regression test is packages/parser/test/non-index-folder-link.test.js.

Verified with Node 22.22.0 after building @docmd/utils, @docmd/tui, and @docmd/parser:

node --test test/non-index-folder-link.test.js
# tests 2, pass 2

The parser suite passed 103 tests after excluding one Windows-only test that also fails on origin/main: the worker_threads determinism test imports a d:\... path as an ESM URL. The mermaid tests passed. pnpm lint and pnpm --filter @docmd/parser build passed; ESLint reported no errors on the touched files (existing no-explicit-any warnings only).

Non-index pages are emitted one directory deeper, and relative links
gain a ../. index.md and README.md normalised to an empty path and
skipped that shift, so the link pointed at the page itself.

Co-authored-by: Cursor <[email protected]>
@mgks

mgks commented Nov 11, 2026

Copy link
Copy Markdown
Member

Welcome to docmd, and thank you for your contribution! 🎉

This is a very clean catch. Handling the depth shift for index.md / README.md relative links on nested non-index pages (<slug>/index.html) resolves a subtle navigation bug where links would previously reload the current page instead of linking up to the parent directory.

The regression test suite in packages/parser/test/non-index-folder-link.test.js covers both index and non-index anchor cases nicely. All tests pass cleanly. Merging! 🚀

@mgks
mgks merged commit 49430ca into docmd-io:main Nov 11, 2026
mgks added a commit that referenced this pull request Nov 11, 2026
…ture additions

Synchronize working branch 'dev-0.9.10' with 'main' following the review,
security audit, and integration of 6 community pull requests alongside our
static asset root mirroring feature.

Merged Community Contributions:
- PR #271 (@GPT-AGI / Ting Zhang): fix(parser): resolve folder-index links from nested pages
  Fixes relative link resolution for non-index folder references from deep subdirectories.
- PR #274 (@svallory): fix(core): build finds 0 pages when an ancestor folder matches .gitignore
  Confines gitignore matching to repository root and avoids empty builds when parent paths match ignore patterns.
- PR #275 (@svallory): fix(build): keep git tree clean after pnpm -r run build
  Eliminates timestamps from generated plugin registry and ignores pre-built native binaries across architectures.
- PR #276 (@svallory): fix(tests): give each test run its own temp fixture root
  Isolates test fixtures into unique run directories under os.tmpdir() to prevent concurrency collisions.
- PR #272 (@svallory): feat(api,core): plugin actions receive caller context; one shared action host
  Introduces shared ActionHost with caller context (identity, mode, transport, headers without cookies), origin allowlisting, and unified rebuild queue.
- PR #273 (@svallory): feat(core): docmd serve, a production server for the built site
  Adds zero-dependency production HTTP/WS server with gzip compression, security headers (CSP, HSTS, CORS), health check endpoints (/healthz, /livez, /readyz), and SPA / clean URL routing.

Working Branch Features Included:
- feat(core): Zero-config static root asset mirroring
  Copies static assets from 'public/' or 'static/' (and docs/public/) directly to the output root ('site/'), preserving directory structure and files like 'funding.json', 'CNAME', and '.well-known/'. Adds canonical 'static' configuration option with support for boolean or custom directory lists.
- feat(cli): --host flag support for dev and serve commands (defaults to loopback 127.0.0.1 for CWE-1385 protection, configurable to 0.0.0.0 for container / LAN hosting).

Documentation Impact:
- Configuration Reference: Document 'static' setting (boolean | string[]).
- CLI Reference: Document 'docmd serve' command options and '--host' flag.
- Plugin Guide: Document ActionHost caller context and execution modes.
@mgks mgks mentioned this pull request Nov 13, 2026
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