Snippets
Reuse parameterized MDX content across multiple pages with the Snippet component.
The <Snippet> component lets you write MDX content once and embed it across multiple pages. It inlines the referenced file at build time — no runtime overhead.
Setup
Configure the snippets directory in publier.config.yaml:
snippets: directory: src/content/snippets # default: content/snippetsThe directory is relative to the project root. Snippet support turns on automatically when the snippets option is set.
Creating a snippet
Add an .mdx file to your snippets directory:
Install the package:
```bashpnpm add {{package}}Snippets are plain MDX — they can contain headings, code blocks, callouts, or any other content.
## Using a snippet
Embed the snippet with the `<Snippet>` component. Pass the filename (including `.mdx`) as the `file` prop:
```mdx<Snippet file="install.mdx" package="@publier/shell" />The {{package}} placeholder is replaced with @publier/shell at build time.
Multiple placeholders
Snippets support any number of named placeholders:
This endpoint requires a {{tier}} plan or higher.See the [pricing page]({{pricingUrl}}) for details.<Snippet file="api-note.mdx" tier="Pro" pricingUrl="/pricing" />Props
| Prop | Type | Description |
|---|---|---|
file | string | Filename of the snippet, including the .mdx extension. Required. |
* | string | Any additional prop replaces the matching {{propName}} placeholder. |
Path safety
The file prop is resolved relative to the snippets directory. Path traversal references (../, /etc/passwd) are rejected with a warning and the <Snippet> node is left untouched.
Directory layout
src/ content/ docs/ getting-started.mdx snippets/ ← configure via snippets.directory install.mdx api-note.mdx prerequisites.mdxSnippet files are not added to the page tree or search index — they exist only to be embedded in other pages.