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.
Configure
Section titled “Configure”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) |
Pull and build
Section titled “Pull and build”pnpm pull:cms # writes src/content/docs/kb/cms/*.mdpnpm buildEach 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.
How it calls the API
Section titled “How it calls the API”The script authenticates with Authorization: Bearer <API key> and pages
through:
GET {CMS_URL}/api/cms/v1/entries/{content-type}?page=1&page_size=100Entries 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.