Skip to content

fix: use canonical slug for folder-page graphs - #14

Open
kalinof wants to merge 2 commits into
quartz-community:mainfrom
kalinof:fix/canonical-folder-page-slug
Open

fix: use canonical slug for folder-page graphs#14
kalinof wants to merge 2 commits into
quartz-community:mainfrom
kalinof:fix/canonical-folder-page-slug

Conversation

@kalinof

@kalinof kalinof commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • prefer Quartz's canonical body[data-slug] when selecting the current Graph node
  • preserve the existing URL and base-path derivation as a fallback
  • normalize both paths with the same slug semantics used by graph-index keys
  • add regression coverage for folder /index pages, ordinary pages, base-path segment boundaries, and the actual browser URL/base-path utility wiring

Problem

A folder-backed page can have these two identities during SPA navigation:

body[data-slug]: projects/example/index
browser URL slug: projects/example

The content index simplifies the canonical /index identity to projects/example/. The Graph component previously rooted the local graph using only the browser URL, so its lookup could miss the valid folder key and render the current page as an isolated node even though links and backlinks were present in contentIndex.json.

Using explicit /index links in content does not fix the current-node mismatch and makes authors compensate for a presentation-layer identity bug.

Fix

Use Quartz's canonical body slug when available. It is the same page identity used to build the generated content index and remains correct across SPA navigation. Keep URL/base-path handling for environments where body metadata is unavailable.

Validation

npm run check
TypeScript: passed
ESLint: passed
Prettier: passed
Vitest: 2 files, 11 tests passed

The correction was also exercised in a real Quartz site with folder-backed and ordinary pages, SPA click-through, and light/dark themes.

Related reports

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.

1 participant