Advanced patterns
---
title: Advanced patterns
description: Two patterns that keep authored sources and derived output in step.
updatedAt: '2026-09-17'
---
## 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:
```ts
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:
```plaintext
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](../install.md); the fields it reads are in the
[CLI reference](../../reference/cli.md).