Partials
Set a partials directory in the preprocessor config. All files in that directory are loaded as partials.
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
markdoc({
partials: join(
dirname(fileURLToPath(import.meta.url)),
'./src/lib/partials',
),
});
# My header
Here's an example of including the header.md file as a partial.
{% partial file="header.md" /%}
{% partial file="header.md" /%}
Passing variables
Partials are like any other tags, so you can pass variables as attributes to them such as:
{% partial file="header.md" variables={name: "My header name"} /%}
and access the variables as you would in a regular Markdoc document:
# {% $name %}