ProsewireDocs

Add Prosewire to Astro

Add a native static or server-rendered Prosewire reader with injected routes or unstyled components.

Scaffold the reader

From an existing Astro project, run:

pnpm create prosewire@latest \
  --url https://publish.example.com \
  --blog fieldnotes \
  --route /blog

The scaffolder detects static or server output, installs @prosewire/astro, and writes pages that can be wrapped in the project’s existing layouts. It refuses to overwrite an existing route.

In a monorepo, run the command from the workspace root. The scaffolder selects the app automatically when there is only one supported app. Otherwise, pass --cwd apps/docs. It updates that app’s manifest and runs installation from the workspace root with the detected package manager, avoiding a nested lockfile.

For the smallest manual setup, register the integration:

import { defineConfig } from "astro/config";
import prosewire from "@prosewire/astro";

export default defineConfig({
  integrations: [
    prosewire({
      baseUrl: "https://publish.example.com",
      publication: "fieldnotes",
      basePath: "/blog",
      siteUrl: "https://www.example.com",
    }),
  ],
});

This injects /blog and /blog/[slug]. Static sites fetch all published content and known slug redirects during the build. Server output fetches per request and sets shared-cache headers. Neither mode needs an API key.

Verify the first build

The deployment URL must be reachable during the production build, and the publication slug must match a publication on that deployment. Publish a post in the dashboard before building the host application:

pnpm build

Run the built application with your deployment’s normal production command. Open /blog and the published article. The index and article should render without a management key or client-side JavaScript. Check that a draft, future scheduled post, archived post, and unknown slug return 404; rename the published post and confirm its previous slug redirects to the replacement.

For static output, this is a snapshot of content and redirects at build time. Rebuild and redeploy after publication, archiving, scheduling changes, or renaming. Server output reads on demand; its configured shared cache can retain an earlier response until it expires.

Own the layout and markup

Injected routes are useful for an immediate reader. Set injectRoutes: false when the publication should live inside your own pages and layouts:

---
import PostArticle from "@prosewire/astro/components/PostArticle.astro";
import { createProsewire } from "@prosewire/astro";
import SiteLayout from "../../layouts/SiteLayout.astro";

const content = createProsewire({
  baseUrl: "https://publish.example.com",
  publication: "fieldnotes",
});
const result = await content.resolvePost(Astro.params.slug ?? "");
if (result.status === "not-found") return new Response("Not found", { status: 404 });
if (result.status === "redirect") return Astro.redirect(`/blog/${result.slug}`, 301);
---

<SiteLayout title={result.post.title}>
  <PostArticle blog={result.blog} post={result.post} basePath="/blog" />
</SiteLayout>

PostList.astro and PostArticle.astro contain semantic markup, stable pw-* classes, and data-prosewire hooks. They ship no stylesheet, inline layout, or client-side JavaScript. Import them as a starting point, style their hooks, copy their small markup into your own component, or use createProsewire directly.

Give setup to an agent

Run the same scaffold command with --agent to print a safe setup prompt instead of writing files. Add --cwd apps/docs to identify a monorepo target. It asks the agent to preserve the host site’s layout and styles and verify the production build.