path_branding:

  • Quartz uses TypeScript brands for nominal path typing; prevents accidental cross-assignment.

brand_example:

type FullSlug = string & { __brand: "full" }
 
// Fails typechecking:
const slug: FullSlug = "some random string"

Path Types

path_types: FilePath: - Absolute disk file path. - File extension required. FullSlug: - Absolute URL path. - No leading/trailing slashes. - May end with index. - Preferred general-purpose slug. SimpleSlug: - Absolute URL path. - Cannot end with /index. - Cannot include file extension. - May include trailing slash for folders. RelativeURL: - Relative URL path. - Must start with . or ... - Cannot end with /index. - Cannot include file extension. - May include trailing slash.

Path Conversions (quartz/path.ts)

graph LR
    Browser{{Browser}} --> Window{{Body}} & LinkElement{{Link Element}}
    Window --"getFullSlug()"--> FullSlug[Full Slug]
    LinkElement --".href"--> Relative[Relative URL]
    FullSlug --"simplifySlug()" --> SimpleSlug[Simple Slug]
    SimpleSlug --"pathToRoot()"--> Relative
    SimpleSlug --"resolveRelative()" --> Relative
    MD{{Markdown File}} --> FilePath{{File Path}} & Links[Markdown links]
    Links --"transformLink()"--> Relative
    FilePath --"slugifyFilePath()"--> FullSlug[Full Slug]
    style FullSlug stroke-width:4px

tests:

  • See quartz/util/path.test.ts for implementation examples.