Skip to content

Astro — overview

@ghostwritr/astro is a Content Layer loader. It pulls your site’s published articles into a content collection at build time — no file syncing, no CMS, no API key. Requires Astro 5+.

You define a collection with ghostwritr({ siteId }), and from then on it’s a normal Astro collection: getCollection, render, <Content />. The Markdown body arrives pre-compiled, the full article shape lands on entry.data, and removed articles drop out on the next build.

npm install @ghostwritr/astro
src/content.config.ts
import { defineCollection } from "astro:content";
import { ghostwritr } from "@ghostwritr/astro";
export const collections = {
articles: defineCollection({
loader: ghostwritr({ siteId: import.meta.env.GHOSTWRITR_SITE_ID }),
}),
};
src/pages/blog/[slug].astro
---
import { getCollection, render } from "astro:content";
export const getStaticPaths = async () =>
(await getCollection("articles")).map((p) => ({ params: { slug: p.id }, props: { p } }));
const { p } = Astro.props;
const { Content } = await render(p);
---
<h1>{p.data.title}</h1>
<Content />

That’s a statically-generated blog reading from the keyless feed. The quickstart fills in SEO and the byline.

Reads hit your site’s static feed at feeds.ghostwritr.io/{siteId}/. The siteId is the unguessable read capability — there is no API key and no authed fallback. A missing feed fails closed: the loader throws a GhostwritrError with code NOT_FOUND and the build stops. See Keyless reads and The content feed.

Build-time only — pair with a redeploy hook

Section titled “Build-time only — pair with a redeploy hook”

The loader runs during astro build. Articles published after a build won’t appear until the next build, so wire a deploy hook to the signed feed.updated webhook to rebuild on publish. See Redeploy on publish and Instant updates.