Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`cms-contentful/`](./cms-contentful/) | **CC** | In progress (CC0) | Vercel's Next.js Blog with Draft Mode (Contentful) on Cloudflare Workers + Static Assets through OpenNext, deployable before a Contentful space exists, and an Orun baseline that instantiates it in one landing (CC2) |

As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
11 changes: 11 additions & 0 deletions specs/epics/cms-contentful/IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# cms-contentful — implementation status

| Milestone | State | Landed |
|---|---|---|
| CC0 — the spec | ✅ | the repository's first commit, CC-1 |
| CC1 — the blog on Workers | planned | CC-2 |
| CC2 — a baseline | planned | CC-3 |

## Departures from the upstream template

Recorded as they land, from CC1 on.
34 changes: 34 additions & 0 deletions specs/epics/cms-contentful/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# cms-contentful — Vercel's Next.js Blog with Draft Mode (Contentful) on Cloudflare Workers

**The template's Next.js blog, rendered on request by one Cloudflare Worker
from a Contentful space — its static assets beside it, draft mode through
the Content Preview API — deployed by Orun to stage and prod on every merge,
live before its owner has a space at all, and the baseline that makes a copy
of it somebody else's blog in one landing.**

| | |
|---|---|
| Status | In progress — CC0 on main |
| Upstream | [vercel/next.js `examples/cms-contentful`](https://github.com/vercel/next.js/tree/canary/examples/cms-contentful) (MIT), at `7356b0b` (2026-10-28) |
| Reference | [cms-sanity](https://github.com/sourceplane/cms-sanity) — the same scaffolding, tests and bootstrap, and the unconnected sample mode this blog copies |
| Key | `CC` |

## Read in this order

1. [design.md](design.md) — the template, how each Vercel piece maps to
Cloudflare, the unconnected blog, the repository and the build, and the
alternative rejected.
2. [implementation-plan.md](implementation-plan.md) — the milestones and
what each one lands.
3. [risks-and-open-questions.md](risks-and-open-questions.md) — what is not
proven, and what was accepted.
4. [IMPLEMENTATION-STATUS.md](IMPLEMENTATION-STATUS.md) — what shipped, and
every departure from the upstream template.

## Milestones

| Milestone | What it lands | Task |
|---|---|---|
| CC0 — the spec | the repository, its intent, CI, tooling and spec index; this doc set | CC-1 |
| CC1 — the blog on Workers | the template in `apps/web`, built by OpenNext into one Worker, with its unconnected sample mode; `tests/web` | CC-2 |
| CC2 — a baseline | the console card, the build document, the context pack and the baseline's tests | CC-3 |
80 changes: 80 additions & 0 deletions specs/epics/cms-contentful/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# cms-contentful — design

## 1. The template

Vercel's [Next.js Blog with Draft Mode (Contentful)](https://github.com/vercel/next.js/tree/canary/examples/cms-contentful)
(Next.js App Router, Tailwind CSS 3, Inter) is a blog whose content is in a
Contentful space: an **Author** type (name, picture) and a **Post** type
(title, slug, date, excerpt, cover image, rich-text content, author). The
home page shows the newest post as a hero and the rest under "More
Stories"; a post page renders its rich text with
`@contentful/rich-text-react-renderer` and two more stories. Every read is a
GraphQL query to Contentful's Content API (`lib/api.ts`); images are
Contentful assets sized by its Images API through a custom `next/image`
loader. Draft mode is turned on by Contentful's preview URL
(`/api/draft?secret=…&slug=…`) and reads drafts through the Content Preview
API; `/api/disable-draft` turns it off. `/api/revalidate` is a webhook that
revalidates the `posts` fetch tag. `npm run setup` imports the content model
(`lib/export.json`) into a space with `contentful-import`.

## 2. How it maps to Cloudflare

| Vercel | Here | Why |
|---|---|---|
| Next.js hosting | One Worker built by `@opennextjs/cloudflare` (`output: 'standalone'`), `public/` and the client chunks in its Static Assets, the static-assets incremental cache | Nothing in the Worker is revalidated |
| Static pages + `generateStaticParams`, the `posts` tag revalidated by a webhook | `/` and `/posts/[slug]` `force-dynamic`, every fetch `cache: "no-store"`; Contentful's API CDN is the cache | Tag revalidation needs a writable cache the static-assets one is not, and a build-time fetch would need the space at build |
| Env vars in the dashboard (or the Vercel integration) | The space id and the delivery token: optional Orun secrets, read at build and inlined into the server bundle. The preview token and the preview and revalidate secrets: Worker secrets, read at request time | The build decides connected or not; draft mode's values never enter the bundle, and a deploy never touches a Worker secret |
| `@contentful/vercel-nextjs-toolkit`'s draft route | `app/api/draft/route.ts`: the preview secret, the post through the Content Preview API, draft mode, a redirect | The toolkit authorises with Vercel's protection-bypass token, which has no Cloudflare twin; the preview URL is the upstream README's, unchanged |
| `next/image` with Contentful's loader | Unchanged (`images.loader: "custom"`) | Contentful sizes the image; the Worker has no optimiser to run |
| `npm run setup` | Unchanged: `pnpm --filter @app/web run setup`, run by a person with a management token | A management token is the space owner's, and nothing in a bootstrap holds one |

## 3. The unconnected blog

The platform brokers Cloudflare, not Contentful, so a bootstrap deploys a
blog whose owner has no space yet. Upstream would fetch
`spaces/undefined` and every page would be a 500. Here a build without both
`CONTENTFUL_SPACE_ID` and `CONTENTFUL_ACCESS_TOKEN` is **unconnected**:
`lib/api.ts` answers every query from `lib/sample.ts` (three posts in the
GraphQL response's shape, their covers and the avatar in `public/sample`),
the layout shows a "connect your Contentful space" notice
(`data-contentful-notice="unconnected"`), the first post is the connect
steps, and `/api/draft` answers 401 with the reason. This is cms-sanity's
pattern, kept to the same shape: the smoke, the e2e tier and the deployment
record all read the notice.

## 4. The repository

cms-sanity's shape (turso v8): `apps/web` (type
`cloudflare-workers-assets-turbo`, lane `isolated`) and `tests/web` (type
`turbo-package`, a vitest suite run on the `dev` rung). No infrastructure:
Contentful is a hosted service. The blog's name is one seam, `SITE_NAME` in
`app/site.ts`, read by the home heading, the page title and every post's
link home. The footer's upstream link (`EXAMPLE_URL` in `lib/constants.ts`)
shares this baseline's slug, so the rename engine protects it.

## 5. The build

`next build` (Turbopack), `opennextjs-cloudflare build --skipBuild`, then
`populateCache local`. `repo-blueprint.yaml` is cms-sanity's: one landing
(`01-product`) places, brands and lands the whole tree, one convergence
builds and deploys stage and prod side by side, and `02-docs` records what
went live. The smoke checks the home page renders its "More Stories"
section and `/api/draft` refuses a request without the preview secret.

## 6. Out of scope

- Embedding the content-model import in the bootstrap: it needs a
management token, which only the space's owner has (cms-sanity's
`sanity init` is a person's step too).
- A cache in the Worker (OpenNext's R2 incremental cache) to bring back
tag revalidation: an upgrade for a high-traffic blog (risk CC-C).

## 7. The alternative rejected

**Static generation at build time, as upstream.** `generateStaticParams`
and static pages would fetch the space during `next build`: a fresh
product has none, so the build would fail or bake the samples in for
good, and a published post would need a rebuild (or an R2 cache and the
webhook) to appear. Rendering on request makes a published post live on the
next visit, keeps the build independent of the space, and costs one
GraphQL request per page, which Contentful's CDN answers.
31 changes: 31 additions & 0 deletions specs/epics/cms-contentful/epic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# The epic's declaration. metadata.name equals the directory name; metadata.key
# is the task-key prefix this epic reserves (CC → CC-1, CC-2, …). Owner, target
# date and health are the platform's — never written here.
apiVersion: orun.io/v1
kind: Epic
metadata:
name: cms-contentful
key: CC
spec:
title: "Vercel's Next.js Blog with Draft Mode (Contentful) on Cloudflare Workers"
summary: "Vercel's Next.js Blog with Draft Mode (Contentful) — posts and authors read from a Contentful space over its GraphQL API, rich text, draft mode through the Content Preview API, and the setup script that imports the content model — runs on Cloudflare Workers + Static Assets through @opennextjs/cloudflare, inside the Cirrus baseline's repository conventions, and becomes an Orun baseline that takes a new blog from nothing to live on stage and prod in one landing, serving bundled sample posts until its owner connects a space."
state: started
milestones:
- name: "CC0 — the spec"
exitCriteria:
- "the repository is born with its intent, CI, tooling and spec index, and this doc set and the task contracts are on main"
tasks: [CC-1]
- name: "CC1 — the blog on Workers"
exitCriteria:
- "apps/web is the upstream template, built by next build, then by OpenNext into one Worker with Static Assets, every page rendered on request"
- "with no space at build the blog serves bundled sample posts under a notice that says how to connect, and draft mode answers 401 with the reason"
- "`pnpm typecheck`, `pnpm lint`, `pnpm test` and `pnpm build` are green"
- "`wrangler dev` serves the home page, every sample post, a 404 for an unknown post, draft mode's 401, leaving draft mode and the webhook's 401"
- "the README says how to run, test, preview, connect and deploy it, and how every Vercel piece maps to Cloudflare"
tasks: [CC-2]
- name: "CC2 — a baseline"
exitCriteria:
- "blueprint.yaml (the console card) and repo-blueprint.yaml (the build) take a new blog from nothing to live on stage and prod in one landing, then record it"
- "a blog built from it carries the blog only, renamed throughout to its own name, repository and Worker, with the template's link intact"
- "Baseline CI is green: contract tests, generated component docs, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the end-to-end tier"
tasks: [CC-3]
39 changes: 39 additions & 0 deletions specs/epics/cms-contentful/implementation-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# cms-contentful — implementation plan

Three milestones, each one reviewed pull request (CC0 is the repository's
first commit), each green before it merges.

## CC0 — the spec (CC-1)

The repository is born: `intent.yaml` with the placeholder workspace
`ws_CHANGE_ME`, `ci.yml` (byte for byte turso-starter's, which plans nothing
until the workspace is set), the shared TypeScript and ESLint configuration,
the spec index, this doc set and the task contracts.

## CC1 — the blog on Workers (CC-2)

- The template's `app/`, `lib/` and configuration in `apps/web`; Next pinned
to 16.3.8 with React 19, `@opennextjs/cloudflare` and `wrangler`.
- `next.config.ts`: the template's custom image loader, the space id and
delivery token inlined at build, `output: 'standalone'`, the workspace
root for the trace. `open-next.config.ts` with the static-assets
incremental cache; `wrangler.jsonc`.
- Pages `force-dynamic`, reads `no-store`; `/api/draft` written out in place
of the Vercel toolkit; an unknown slug a 404.
- The unconnected sample mode: `lib/sample.ts`, `public/sample`, the notice.
- `SITE_NAME` in `app/site.ts`; `EXAMPLE_URL` in `lib/constants.ts`.
- `component.yaml`: the deploy contract, the space's optional secret refs
and the smoke. `tests/web`: the identity, the sample mode, the GraphQL
reads, the rich-text body and the draft route.
- The README's "How it maps to Vercel".

## CC2 — a baseline (CC-3)

cms-sanity's machinery, renamed: `blueprint.yaml`, `repo-blueprint.yaml`,
`.baseline/` (identity, the product's README with "Connecting Contentful",
its AGENTS.md, task contracts), `tooling/rebrand` (the upstream link
protected), `tooling/bootstrap`, `hooks/render-deployment-docs.sh` (probing
`/` and `/api/draft`, and recording whether each blog reads a space yet),
`docs/phases/`, the context pack, `testing/` (the leak and placement gates
on this tree's files; the e2e tier reading every route the blog promises)
and `baseline.yml` / `tag.yml`.
13 changes: 13 additions & 0 deletions specs/epics/cms-contentful/risks-and-open-questions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# cms-contentful — risks and open questions

| ID | Risk | State | Notes |
|---|---|---|---|
| CC-A | `baseline-v1` is not yet proven live | OPEN | Proven offline in Baseline CI, unconnected: the offline bootstrap with the blueprint's own hooks, the stage lane's own steps in a staged job tree, the blog served by `wrangler dev` and smoke-tested with the component's own command. A console bootstrap, then a space connected to it, closes it |
| CC-B | Draft mode has not met a real space | OPEN | `/api/draft` is tested with a mocked fetch and served unconnected (401); Contentful's Open preview against a real space, through the Worker, is still to do. The cookie is set on a top-level navigation, so no third-party-cookie rule applies |
| CC-C | Every page view is a GraphQL request to Contentful | ACCEPTED | The home page makes one, a post page two; Contentful's API CDN answers them, and its rate limits apply only to what the CDN misses. A busy blog's upgrade is OpenNext's R2 incremental cache with the template's tag revalidation back on |
| CC-D | Setting a secret redeploys nothing | ACCEPTED | The space id and token are read at build; the owner redeploys by hand or with the `# orun: redeploy` stamp in `apps/web/component.yaml` (README, "Connecting Contentful") |
| CC-E | The delivery token is inlined into the Worker's server bundle | ACCEPTED | It reads published content only — Contentful's own guidance treats a Content Delivery API token as safe for client code — and only `server-only` code names it, so no browser receives it. The preview token, which reads drafts, is a Worker secret read at request time |
| CC-F | `/api/revalidate` has nothing to revalidate | ACCEPTED | Kept as upstream, checking its secret; with every page rendered on request a published post is live on the next visit with no webhook |
| CC-G | Next 16.3.8 and React 19, not upstream's `next: latest` and React 18 | ACCEPTED | `latest` resolves to 16.4, which OpenNext does not support yet; the Contentful renderer is on its React 19 line (16.x) |
| CC-H | A wrong space id or token shows an empty blog | ACCEPTED | The GraphQL error answers no posts: the home page renders with none, a post page is a 404 (upstream: a 500). BOOTSTRAP.md's troubleshooting names the causes |
| CC-I | stack-tectonic 0.19.0, not 0.20.0 | ACCEPTED | 0.20.0's lane-shared install links each job's `node_modules` out of its tree, which Turbopack refuses |
15 changes: 15 additions & 0 deletions tasks/CC-1.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: CC-1
title: "The spec"
spec:
goal: The cms-contentful repository is born with its intent, CI, tooling and spec index, and the cms-contentful epic — declaration, doc set and task contracts — is on main
affects:
- specs/epics/cms-contentful
- specs/epics/README.md
- tasks
doneWhen:
- epic.yaml, README, design, implementation plan, risks and status are on main
- the three task contracts exist
gates: []
18 changes: 18 additions & 0 deletions tasks/CC-2.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: CC-2
title: "The blog on Workers"
spec:
goal: Vercel's Next.js Blog with Draft Mode (Contentful) runs on Cloudflare Workers + Static Assets through OpenNext, deployable before a Contentful space exists, with its tests and a README that says how it maps to Vercel
affects:
- apps/web
- tests/web
- pnpm-lock.yaml
- pnpm-workspace.yaml
- README.md
- .gitignore
doneWhen:
- pnpm typecheck, lint, test and build are green
- wrangler dev serves the home page, every sample post, a 404 for an unknown post, and draft mode's 401 with the reason, with no space behind it
gates: []
29 changes: 29 additions & 0 deletions tasks/CC-3.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: orun.io/v1
kind: TaskContract
metadata:
name: CC-3
title: "cms-contentful becomes an Orun baseline"
spec:
goal: blueprint.yaml and repo-blueprint.yaml take a new Contentful-backed blog from nothing to live on stage and prod in one landing, held by Baseline CI
affects:
- blueprint.yaml
- repo-blueprint.yaml
- BOOTSTRAP.md
- .baseline
- .github/workflows/baseline.yml
- .github/workflows/tag.yml
- ai/context
- docs/phases
- hooks
- testing
- tooling/rebrand
- tooling/bootstrap
- tooling/catalog
- apps/web/docs
- tests/web/docs
- specs/epics/cms-contentful
- README.md
doneWhen:
- every Baseline CI tier is green
- a blog placed from it carries the blog only, branded, with the template's link intact
gates: []
Loading