@openpolicy/astro
v0.0.23
Published
Astro integration for compiling OpenPolicy documents at build time
Maintainers
Readme
@openpolicy/astro
Astro integration for compiling OpenPolicy policy documents at build time.
A first-class Astro integration that compiles defineConfig() configs to Markdown or HTML — on every build and on save in dev mode. Delegates to @openpolicy/vite under the hood.
Install
# Recommended — auto-updates astro.config.mjs
npx astro add @openpolicy/astro
# Also install the SDK for defining policies
bun add @openpolicy/sdkOr manually:
bun add -D @openpolicy/astro @openpolicy/vite
bun add @openpolicy/sdkSetup
// astro.config.mjs
import { defineConfig } from "astro/config";
import { openPolicy } from "@openpolicy/astro";
export default defineConfig({
integrations: [
openPolicy({
formats: ["markdown"],
outDir: "src/generated/policies",
}),
],
});Options
| Option | Type | Default | Description |
|---|---|---|---|
| configPath | string | "openpolicy.ts" | Path to the unified policy config file, relative to the Astro root. |
| formats | OutputFormat[] | ["markdown"] | "markdown" or "html" |
| outDir | string | "public/policies" | Output directory, relative to the Astro root |
Using the output
Because the generated files land in src/, Astro can import them as Markdown components:
---
// src/pages/privacy.astro
import { Content } from "../../generated/policies/privacy-policy.md";
---
<div class="prose">
<Content />
</div>Documentation
openpolicy.sh/docs/getting-started/astro
