Hey folks 👋
I built an Astro starter for a blog whose posts come from a headless writing app (Tamable, which I make). Sharing it for the setup, which might be useful even if you never use Tamable.
The shape
- output: 'static' with the Node adapter. Every page is prerendered. Only two routes run on demand: draft previews (/preview/[...token]) and the deploy webhook (/api/deploy).
- When you publish, the app calls /api/deploy with a signed request. The route checks the signature and the timestamp, then calls your host's build hook. Going through the route means only the app can trigger builds, not anyone who learns the hook's URL.
- If a build fails, your host keeps serving the previous version.
Astro bits I enjoyed using
- An integration that builds the redirects. At build time it reads renamed posts from the API, turns them into 301s, and hands them to Astro's redirects option. The live server never asks the API about redirects. The same step stops the build when there are no published posts, so a wrong key can't publish an empty blog (ALLOW_EMPTY_BLOG=true to opt out).
- astro:env for the secrets. The read key, webhook secret and build hook URL are server secrets, so none of them ends up in browser code or gets baked into the build.
- One address per page. trailingSlash: 'never', plus a few lines of node:http in server.mjs that collapse leading slashes (//blog/ becomes /blog/), so a trailing-slash redirect can never point at another host.
What else is in it
- Posts at /blog/{slug} with tags, series, reading time, covers, and SEO fields (canonical, Open Graph, JSON-LD)
- RSS, sitemap and robots.txt
- Optional redirects from an old Ghost blog
- Light and dark themes on CSS variables, Inter and JetBrains Mono self-hosted from Fontsource
- /dev/blocks in development shows every block a post can contain, for styling prose
Try it without an account
The repo ships a fake API with a few made-up posts:
npm install
npm run fake-tamable &
TAMABLE_API_URL=http://localhost:4010/api/v1 TAMABLE_READ_KEY=fixture npm run dev
Repo: https://github.com/tamable-app/astro-blog
It runs on any Node host. For Netlify, Vercel or Cloudflare, swap the adapter, or delete the two on-demand routes and point the webhook straight at the build hook.
For real posts you'd write them in Tamable (14 days free, no card), where your AI drafts from your own words and you approve before anything goes out.
One thing I'm unsure about: redirects are worked out at build time through the integration, while trailing slashes and Ghost addresses go through a small fetch handler at request time. Would you have put it all in middleware instead?