Zero-build privacy policies with Astro
6 hours ago
- #astro-integration
- #policy-generation
- #static-site
- OpenPolicy's Astro integration previously generated Markdown files at build time via a plugin, adding friction with extra packages and generated directories.
- The new approach eliminates the plugin and generated files by directly compiling policies in Astro's frontmatter using three core packages: @openpolicy/sdk, @openpolicy/core, and @openpolicy/renderers.
- Users define a centralized config in src/lib/openpolicy.ts with details for privacy, terms, and cookie policies, which can be filled quickly using AI tools like Claude.
- Each dedicated page (e.g., privacy.astro) imports the config, compiles the policy, and renders it to HTML at build time with zero JavaScript shipped to the browser.
- Benefits include no generated files or directory management, no plugin configuration in astro.config.mjs, support for all three policy types from one config, and simpler inline compilation.
- OpenPolicy+ offers advanced features like cloud-based consent tracking, PR automation for compliance, and hands-on onboarding for further needs.