Repository navigation
fix(nav-order): respect navigation order for notes using path rewrite rules - #378
Merged
Merged
Conversation
Path rewrite rules produce a dg-path in the published frontmatter that
already includes the ".md" extension (e.g. "Path Rewriting/note.md" ->
dg-path "note.md"). getPermalinkMeta appended ".md" unconditionally,
yielding a double extension ("note.md.md") for the file-tree leaf key.
The stored navigationOrder uses stems ("note"), and sortTree's resolver
only tries "note" / "note.md" — so the double-extension key never
matched and the custom order was silently dropped to default sort.
Strip a trailing ".md" before re-appending it so leaf keys are always
single-extension, regardless of whether dg-path carried the extension.
Note names containing other dots (e.g. "my-note-v1.2") are preserved.
Also declare the implicit globals in assignNested (only worked in
CommonJS sloppy mode) and convert filetreeUtils.test.js to ESM imports
so it actually runs under `vitest run`.
Fixes #786
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Fixes #786 — navigation order is silently ignored for any note affected by a path rewrite rule, even after re-checking and re-saving the order in the plugin.
Root cause
When a path rewrite rule applies, the plugin writes a
dg-pathinto the published frontmatter that includes the.mdextension (e.g.Path Rewriting/note.md→dg-path: note.md).getPermalinkMetainfiletreeUtils.jsbuilt the file-tree leaf key withfolders[last] += ".md", assumingdg-pathhad no extension (true for manually-setdg-pathand forfilePathStem, which Eleventy strips). For rewrite-rule notes this produced a double extension:note.md.md.The stored
navigationOrderuses stems (note), andsortTree's resolver only triesnote/note.md. Thenote.md.mdkey never matched, so the note dropped to default sort and the custom order was lost. This is why the bug only appears with rewrite rules.Fix
Strip a trailing
.mdbefore re-appending it, so leaf keys are always single-extension regardless of whetherdg-pathcarried the extension. Only.mdis stripped (not arbitrary dots), so names likemy-note-v1.2are preserved.Also in this change:
assignNested(previously only worked in CommonJS sloppy mode; threw under strict/ESM and leaked globals).filetreeUtils.test.jsto ESM imports so it actually runs undervitest run(it was using jest-style globals and not running in the suite).Tests
Added 3 tests covering the rewrite-rule scenario (root, nested folder, and dot-in-name). Confirmed they fail before the fix (
note.md.mdkeys) and pass after.🤖 Generated with Claude Code