Skip to content

fix(path): resolve short wikilinks to folder notes - #5

Open
alastairsounds wants to merge 1 commit into
quartz-community:mainfrom
alastairsounds:fix/folder-note-shortest-links
Open

alastairsounds wants to merge 1 commit into
quartz-community:mainfrom
alastairsounds:fix/folder-note-shortest-links

Conversation

@alastairsounds

Copy link
Copy Markdown

slugifyFilePath rewrites Foo/Foo.md to the slug Foo/index. The last path segment is then index, so the shortest strategy in transformLink never matches a short [[Foo]] link. The link resolves to a root-relative path that does not exist. No error occurs.

transformLink now retries against the folder name. The retry runs only under two conditions:

  • The first pass finds no match.
  • The link has one segment.

If a real file has that name then the first pass matches it and the retry does not run.

These conditions are necessary. A version without them changed links that already resolved. If a vault holds both Archive/Note.md and Folder/Note/Note.md, a short [[Note]] link keeps Archive/Note as its target.

Tests

Two cases in test/path.test.ts:

  • resolves a folder note by its folder name fails without the change.
  • prefers a real file over a folder note of the same name passes with the change and without it. This case makes sure that a real file keeps priority.

All 107 tests pass. The typecheck, eslint, prettier, and vitest gates in npm run check give no error.


Resolves #4

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.

Short wikilinks to a folder note resolve to a nonexistent root-level path

1 participant