diff --git a/package-lock.json b/package-lock.json index 034c29e..9ea0a39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1857,7 +1857,7 @@ }, "node_modules/@quartz-community/utils": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/quartz-community/utils.git#cf1450b6f744755c16ca0d301db08c2ade6cfb67", + "resolved": "git+ssh://git@github.com/quartz-community/utils.git#e17fc8d5f027eed1dfba1848ef1dd41633521558", "dev": true, "license": "MIT", "dependencies": { diff --git a/quartz/util/path.test.ts b/quartz/util/path.test.ts index e85f1d0..b6fb9fb 100644 --- a/quartz/util/path.test.ts +++ b/quartz/util/path.test.ts @@ -120,6 +120,18 @@ describe("transforms", () => { ["test/special chars?.md", "test/special-chars"], ["test/special chars #3.md", "test/special-chars-3"], ["cool/what about r&d?.md", "cool/what-about-r-and-d"], + // Obsidian "Folder Notes" convention: folder/folder.md is the folder's landing page + ["characters/characters.md", "characters/index"], + ["fiction/books/books.md", "fiction/books/index"], + ["a/a/a.md", "a/a/index"], + // Top-level single-segment: NOT rewritten (parentFolder storage, out of scope) + ["characters.md", "characters"], + // Non-matching last two segments: no rewrite + ["characters/alice.md", "characters/alice"], + ["characters/sub/characters.md", "characters/sub/characters"], + // Folder literally named "index" is unaffected by the rewrite + ["index/index.md", "index/index"], + ["docs/index/index.md", "docs/index/index"], ], path.slugifyFilePath, path.isFilePath, @@ -127,6 +139,16 @@ describe("transforms", () => { ) }) + test("slugifyFilePath + simplifySlug end-to-end canonicalization", () => { + // Both folder-note conventions must produce identical user-facing URLs. + const indexStyle = path.simplifySlug(path.slugifyFilePath("characters/index.md" as any)) + const folderNameStyle = path.simplifySlug( + path.slugifyFilePath("characters/characters.md" as any), + ) + assert.strictEqual(indexStyle, folderNameStyle) + assert.strictEqual(indexStyle, "characters/") + }) + test("transformInternalLink", () => { asserts( [