Integrations
OpenAPI, Mermaid, KaTeX, search, analytics — the integrations Publier ships or auto-detects, and how to add your own.
Publier builds on Astro 7. The scaffolder explicitly registers MDX, Qwik, syntax highlighting, sitemap, and Pagefind integrations; docsShell() warns when a required integration is missing and does not add it. It supplies Publier’s Markdown pipeline, detects Mermaid when installed, and reads analytics, fonts, and content variables from publier.config.yaml. See Configuration for the integration order.
The Astro config snippets below focus on individual options. Apply those options to your existing configuration and retain the scaffolded integration array; the snippets do not replace the complete config.
@publier/openapi
Generate API reference pages from an OpenAPI 3.x spec at build time. AsyncAPI has partial content-source and component APIs, but no MDX file generator; see the AsyncAPI limits.
pnpm add @publier/openapiName the spec and the route its pages live under in publier.config.yaml:
integrations: openapi: - spec: ./specs/api.openapi.yaml # project-relative path or https URL path: /docs/api # below /docs; the defaultPublier writes one page per operation into src/content/docs/<path> on every publier dev and publier build, groups them by tag in the default docs sidebar (tag name as label, spec order), and gitignores the folder. integrations.asyncapi does not run a generator today. To generate by script instead, call generateFiles from @publier/openapi/generate; the OpenAPI guide covers both.
See the OpenAPI guide for the full walkthrough.
CLI reference
Generate the reference pages of a command line from its usage spec at build time. Name the spec and the route its pages live under in publier.config.yaml:
integrations: cli: - format: usage # the only format today source: ./reference/mycli.usage.kdl # project-relative path or https URL path: /docs/cli # below /docsPublier writes a root page and one page per command into src/content/docs/<path> on every publier dev and publier build, and gitignores the folder. See the CLI reference guide for how to produce the spec and what the pages hold.
SDK reference
Generate the reference pages of a library from its documentation tool’s own output at build time. For Python that is griffe’s JSON dump; TypeScript (TypeDoc) and Rust (rustdoc) work the same way:
integrations: sdk: - sdk: mypackage # entries sharing a name are one SDK language: python format: griffe # or typedoc, rustdoc source: ./reference/mypackage.griffe.json # project-relative path or https URL path: /docs/sdk/python # below /docsPublier writes a library page, one page per module and one per class into src/content/docs/<path> on every publier dev and publier build, and gitignores the folder. See the SDK reference guide for the dump command and what the pages hold.
Search
Publier’s search is powered by Pagefind. After every build, the scanner runs against your emitted HTML and writes a static index that ships alongside your site. There’s no server component and no proprietary index format.
The scaffold registers astro-pagefind explicitly to build the index. Keep pagefind() in your Astro integration array; docsShell() supplies the search dialog but does not register the indexer. The dialog opens on Cmd/Ctrl+K or the header search button and inherits your theme tokens.
For what the index covers, how to leave pages out and what a host must serve, see Search.
To disable Publier’s search dialog:
import { docsShell } from '@publier/shell/integration';export default defineConfig({ integrations: [docsShell({ search: false })],});When search: false, the dialog is skipped; the header search button becomes a no-op unless you wire your own publier:search-toggle listener. Also remove pagefind() if you want to stop generating its index, and set search.enabled: false in publier.config.yaml to hide the header trigger.
Dev-server note: the index is only generated at build time, so on a brand-new clone with no prior build the dialog has nothing to search. Run publier build once; subsequent publier dev sessions serve the previously built index (Check that the index was written).
Diagrams — Mermaid
Install the packages and Publier picks them up automatically. No config changes.
pnpm add astro-mermaid mermaidThen use fenced mermaid blocks in any MDX file:
```mermaidflowchart LR A[MDX] --> B(Publier) --> C[Static HTML]```Dark/light theme follows ThemeToggle automatically.
To disable Mermaid even when the packages are installed, pass docsShell({ mermaid: false }) explicitly.
Math — KaTeX
Math is on by default. @publier/shell ships remark-math, rehype-katex and katex, so there is nothing to install. To turn it off:
import { defineConfig } from 'astro/config';import tailwind from '@tailwindcss/vite';import { docsShell } from '@publier/shell/integration';
export default defineConfig({ integrations: [docsShell({ math: false })], vite: { plugins: [tailwind()] },});With math on, write inline or display math in any MDX file:
Inline: $E = mc^2$
Block:$$\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$See the Math Equations guide for the full reference.
Analytics
Declare analytics in publier.config.yaml — Publier adds the provider snippets to the <head> of every page. Five providers are supported out of the box, plus arbitrary custom scripts. For what Publier does and does not do with them, Content-Security-Policy and delivery checks, see Analytics.
Google Analytics 4
analytics: ga4: measurementId: G-XXXXXXXXXXPostHog
analytics: posthog: apiKey: phc_xxxxxxxx host: https://app.posthog.com # optional, defaults to https://app.posthog.comPlausible
analytics: plausible: domain: example.com selfHosted: https://plausible.my-host.com # optional, for self-hosted instancesFathom
analytics: fathom: siteId: ABCDEFGHUmami
analytics: umami: websiteId: 00000000-0000-0000-0000-000000000000 src: https://analytics.my-host.com/script.jsCustom scripts
Need a tag that isn’t one of the built-in providers? Add arbitrary scripts:
analytics: scripts: - src: https://my-cdn.example.com/my-tag.js async: true - content: "window.dataLayer = window.dataLayer || [];" placement: headCustom scripts with no placement, or with placement: head, are written into each page’s <head> at build time, in the order they appear in the config. Scripts marked placement: body are written at the end of <body>, just before </body>. External scripts support the async / defer flags.
Custom fonts
Declare web fonts in publier.config.yaml. Each slot (heading, body, mono) sets --publier-font-<slot>, which feeds --font-heading, --font-body (and --font-sans, which follows the body font) and --font-mono:
fonts: heading: family: Inter googleFontsUrl: https://fonts.googleapis.com/css2?family=Inter weight: "600" body: family: Inter googleFontsUrl: https://fonts.googleapis.com/css2?family=Inter mono: family: JetBrains Mono src: /fonts/JetBrainsMono-Regular.woff2 weight: "400"A slot with googleFontsUrl loads family from Google Fonts in one weight (default 400) and style. Only the key’s presence matters: the URL itself, including any weight list in it, is not read. A slot with src loads a local file, a path under public/ such as /fonts/x.woff2. A slot with only family points its variable at a font already installed on the reader’s system.
Content variables
Centralize repeated strings (version numbers, product names, URLs) in publier.config.yaml:
vars: productName: My Product version: "2.5.0" supportEmail: support@example.comUse them with {{key}} interpolation in any MDX/Markdown text:
Install {{productName}} v{{version}}: `pnpm add my-product@{{version}}`.Need help? Email {{supportEmail}}.Code blocks are not interpolated — placeholders inside fenced code are rendered literally.
Adding your own remark/rehype plugins
Publier auto-wires the standard plugins. Append your own via Astro’s markdown config:
import { defineConfig } from 'astro/config';import { docsShell } from '@publier/shell/integration';import remarkSmartypants from 'remark-smartypants';import rehypeExternalLinks from 'rehype-external-links';
export default defineConfig({ integrations: [docsShell()], markdown: { remarkPlugins: [[remarkSmartypants, { dashes: 'oldschool' }]], rehypePlugins: [[rehypeExternalLinks, { target: '_blank', rel: ['noopener'] }]], },});User plugins run after Publier’s built-ins. See Plugins for the full list and execution order.