Frameworks
Astro
Generate a static article page from a pinned published release.
PeopleTide Content · HTTP integration guides
1. Prepare your project.
Use an Astro project with Node 22+. Save the shared helper as src/lib/delivery.js and use the unprefixed CONTENT_* settings in .env. This example generates /articles/welcome at build time.
2. Add the shared delivery helper.
Copy this helper into the path named above. It follows a single published release without exposing authoring credentials.
// delivery.js — no SDK or API key required. Node 22+ or a modern browser.
export async function getArticle({ origin, organization, site, slug }) {
const base = new URL(origin);
if (base.protocol !== 'https:' && !['localhost', '127.0.0.1'].includes(base.hostname)) {
throw new Error('Use an HTTPS Content origin');
}
if (![organization, site].every(id => /^[a-f0-9-]{36}$/.test(id))) {
throw new Error('Set your organization and site UUIDs');
}
const prefix = '/delivery/v1/' + organization + '/' + site + '/';
async function read(path) {
const url = new URL(path, base);
if (url.origin !== base.origin || !url.pathname.startsWith(prefix) || url.search || url.hash) {
throw new Error('Unexpected delivery URL');
}
const response = await fetch(url, {
credentials: 'omit', cache: 'no-store', redirect: 'error',
signal: AbortSignal.timeout(8000),
});
if (!response.ok) throw new Error('Content delivery returned ' + response.status);
return response.json();
}
const current = await read(prefix + 'current.json');
const manifest = await read(current.url);
const entry = manifest.entries.find(item => item.type === 'article' && item.slug === slug);
if (!entry) return null;
const document = await read(entry.url);
return { releaseId: current.releaseId, document };
}Connect and render.
Publish an article of type article with slug welcome and a body field before running the example. Split the labelled files into the paths shown.
---
// src/pages/articles/welcome.astro
import { getArticle } from '../../lib/delivery.js';
const result = await getArticle({ origin: import.meta.env.CONTENT_ORIGIN,
organization: import.meta.env.CONTENT_ORGANIZATION_ID,
site: import.meta.env.CONTENT_SITE_ID, slug: 'welcome' });
if (!result) throw new Error('Publish the welcome article before building');
const article = result.document;
---
<html lang="en"><head><title>{article.title}</title></head>
<body><article><h1>{article.title}</h1>
<p style="white-space: pre-wrap">{article.fields.body}</p></article></body>
</html>Choose when content refreshes.
Static output refreshes only when rebuilt and deployed. A missing article or upstream failure deliberately fails the build so an incomplete candidate is not deployed. For on-demand rendering, install an Astro server adapter and return the appropriate HTTP 404/503 response.
Verify success and failure.
Run npm run build, then npm run preview and visit /articles/welcome. Change the article and publish: the old build must remain unchanged until rebuilt. Confirm an unpublished fixture causes the build to fail.