yingjieli-content-store v1.0.0
subsystem yingjieli.site
capsule://quake0day/[email protected]
Single source of truth for all editable site content of yingjieliartist.com:
hero, bio, exhibitions, contact, and the works catalog. Backed by Cloudflare
KV (binding YL_DATA) with an in-code DEFAULT_DATA fallback for first boot.
The DEFAULT_DATA value is injected at reconstruct time from site-data.json,
so the same capsule can power any artist's portfolio.
Owns
- the schema of the site-content blob (hero, bio, exhibitions, contact, works[])
- GET /api/data (public read, 30s edge cache + stale-while-revalidate)
- PUT /api/data (admin-only full replace)
- POST /api/data?seed=1 (admin-only reset to DEFAULT_DATA)
- the next-work-number helper (zero-padded 3-digit num)
Does not own
- storage of image bytes (see yingjieli-image-store)
- who is allowed to write (see yingjieli-admin-auth)
- the values inside DEFAULT_DATA (those come from site-data.json at reconstruct)
AI orientation
Single source of truth for editable content. Everything visible on the
public site that an admin can edit lives in one JSON blob at KV key
site:data:v1. The blob has a fixed top-level shape — hero, bio,
exhibitions, contact, works — and PUT validates that shape exists
before writing.
Avoid
- Sharding the content blob across multiple KV keys.
- Reading or writing KV from anywhere outside this capsule's helpers.
- Storing raw image bytes in this blob; only filename references.
Provides
http_api:data-read— GET /api/data → full content JSON. Public.http_api:data-write— PUT /api/data → replace full content blob. Admin only.library:data-helpers— readData, writeData, nextWorkNum, DEFAULT_DATA.
Requires
library:auth-helpersfromyingjieli-admin-auth— isAuthed(request, env) is called for PUT and seed.env:YL_DATA— Cloudflare KV namespace binding.
Dependencies
Capsules
yingjieli-admin-auth>=1.0.0 <2.0.0
Runtime
node>=18cloudflare-pages*
Invariants (must always hold)
- The content blob always has exactly these top-level keys; PUT rejects anything missing.
- DEFAULT_DATA is what an empty KV returns — there is no other fallback path.
- Image filenames in `works[].file` reference keys served by yingjieli-image-store.
Source files (2)
Click any file to view its content; the path on the right shows where the file lands when this capsule is installed.
src/api/data.js→functions/api/data.jssrc/_lib/data.js→functions/_lib/data.js
Plus capsule.yaml and
install.json.