Skip to main content

Advanced patterns

Derive identity from the path

The extensionless physical path is the document identity, so nothing needs to declare one. A helper that reads it is the whole rule:

export function documentId(sourcePath: string): string {
  return sourcePath.replace(/\.(md|mdx)$/, '');
}

Because identity comes from the path, renaming a file renames the document, and the old path only keeps working if a redirect is recorded for it.

Keep an unhighlighted block exact

A plaintext fence is excluded from highlighting deliberately, so its body survives exactly as authored, including the indentation used for alignment:

src/content/docs/dev-stash/guide/advanced/patterns.md
  -> /dev-stash/docs/guide/advanced/patterns
  -> /dev-stash/docs/guide/advanced/patterns/preview
  -> /dev-stash/docs/guide/advanced/patterns/raw

This page sits three directory levels below the documentation collection root, which is what makes it useful for checking breadcrumbs and sidebar order at depth. The rename these patterns describe is the one recorded on install the example workflow; the fields it reads are in the CLI reference.