Skip to content

Pulling content from the CMS

Platform instances expose a headless CMS API: content types, entries, and globals, readable with a scoped API key. This starter includes scripts/pull-cms.mjs, which fetches published content entries at build time and writes them into the knowledge base as pages — so non-developers can edit KB articles in the CMS while the site stays fully static.

Set three environment variables (for local use, a .env file works — it is gitignored):

Variable Meaning
CMS_URL Base URL of your platform instance (e.g. https://community.example.com)
CMS_API_KEY An API key with the cms-read scope (blu_sk_...)
CMS_CONTENT_TYPE The content-type slug to pull (default: articles; the API accepts articles, topics, posts, forums, categories)
Terminal window
pnpm pull:cms # writes src/content/docs/kb/cms/*.md
pnpm build

Each published entry becomes a page under Knowledge Base using the entry’s slug, with its title/description and body taken from the entry attributes.

If CMS_URL or CMS_API_KEY is unset, pull:cms prints a warning and exits successfully with no changes — CI without CMS credentials still builds the static content in this repo.

The script authenticates with Authorization: Bearer <API key> and pages through:

GET {CMS_URL}/api/cms/v1/entries/{content-type}?page=1&page_size=100

Entries come back with slug and an attributes object holding the fields your content type defines (title, body, …). Only entries whose publication status (attributes.status) is published are written — drafts and archived entries are skipped.