From 83cc8efabefbda34b84364ab2b2596a5efbef74f Mon Sep 17 00:00:00 2001 From: Amen <2668333+amenophis1er@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:26:26 -0500 Subject: [PATCH] fix: sample content no longer sends API-only projects to a Studio (#17) --- files/content/conference/src/trokky/seed.ts | 2 +- files/content/conference/src/trokky/structure.ts | 3 ++- files/content/magazine/src/trokky/schemas.ts | 2 +- files/content/magazine/src/trokky/seed.ts | 14 +++++++------- files/content/magazine/src/trokky/structure.ts | 3 ++- test/generate.test.ts | 6 ++++++ 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/files/content/conference/src/trokky/seed.ts b/files/content/conference/src/trokky/seed.ts index 658ddac..e120f80 100644 --- a/files/content/conference/src/trokky/seed.ts +++ b/files/content/conference/src/trokky/seed.ts @@ -2,7 +2,7 @@ * Sample content, created the moment the instance is claimed. * * An empty CMS shows an empty site, and the first minute decides whether a newcomer keeps - * going. So the new owner’s first sight of both the site and the Studio is a whole working + * going. So the new owner’s first sight of the content is a whole working * conference — six tracks, eight speakers, a fourteen-slot program, sponsors, a venue with * tickets — that they can edit or delete. Every document id is fixed, so seeding twice is * harmless; sessions are only created when there are none. This template ships no media: diff --git a/files/content/conference/src/trokky/structure.ts b/files/content/conference/src/trokky/structure.ts index ceee216..3110b38 100644 --- a/files/content/conference/src/trokky/structure.ts +++ b/files/content/conference/src/trokky/structure.ts @@ -1,5 +1,6 @@ /** - * How content is arranged in the Studio sidebar. + * How content is arranged: the Studio's sidebar, when there is one, and the document id each + * singleton is opened and first created under, which the API uses too. * * The schema decides what a singleton is; this only decides where things appear and which * document id the singleton uses. diff --git a/files/content/magazine/src/trokky/schemas.ts b/files/content/magazine/src/trokky/schemas.ts index 9de00b7..cb3be1d 100644 --- a/files/content/magazine/src/trokky/schemas.ts +++ b/files/content/magazine/src/trokky/schemas.ts @@ -3,7 +3,7 @@ * * Chosen because it exercises what a newcomer evaluates a CMS on — references both ways, * rich text, media in two kinds (images and PDFs), drafts, slugs, a singleton — in a shape - * everyone already understands. Rename, add and remove freely; the Studio follows the schema. + * everyone already understands. Rename, add and remove freely; the Studio and the API follow the schema. */ export const settingsSchema = { diff --git a/files/content/magazine/src/trokky/seed.ts b/files/content/magazine/src/trokky/seed.ts index b41bdc6..a4121d8 100644 --- a/files/content/magazine/src/trokky/seed.ts +++ b/files/content/magazine/src/trokky/seed.ts @@ -2,7 +2,7 @@ * Sample content, created the moment the instance is claimed. * * An empty CMS shows an empty site, and the first minute decides whether a newcomer keeps - * going. So the new owner's first sight of both the site and the Studio is a working magazine — + * going. So the new owner's first sight of the content is a working magazine — * illustrated, with authors, categories, downloadable documents and pages — that they can edit * or delete. Every document id is fixed, so seeding twice is harmless; media is only uploaded * when there are no articles yet. @@ -20,7 +20,7 @@ export type SeedAssetReader = (path: string) => Promise const P = { _status: 'published' } as const -/** The value the Studio's media field reads and writes. */ +/** The value a media field holds, as the Studio and the API read and write it. */ const media = (id: string, alt?: string) => ({ _type: 'media', asset: { _type: 'mediaAsset', _ref: id }, ...(alt ? { alt } : {}) }) const daysAgo = (n: number) => new Date(Date.now() - n * 86_400_000).toISOString() @@ -56,8 +56,8 @@ export async function seedSampleContent(core: TrokkyCore, readAsset: SeedAssetRe { label: 'About', href: '/about' }, { label: 'Contact', href: '/contact' } ], - footer: 'Published with Trokky. Everything you see here is editable in Studio.', - footer_fr: 'Publié avec Trokky. Tout ce que vous voyez se modifie dans Studio.' + footer: 'Published with Trokky. Everything you see here is content you can edit.', + footer_fr: 'Publié avec Trokky. Tout ce que vous voyez est du contenu modifiable.' }) await core.saveDocument('author', { id: 'author-ama', ...P, name: 'Ama Kodjo', slug: 'ama-kodjo', role: 'Editor', bio: 'Runs the magazine and writes the long pieces. Previously ten years in print.', avatar: media(a1, 'Ama Kodjo') }) @@ -76,7 +76,7 @@ export async function seedSampleContent(core: TrokkyCore, readAsset: SeedAssetRe cover: media(c1, 'A desk with a notebook and coffee'), author: 'author-ama', category: 'category-tech', featured: true, publishedAt: daysAgo(0), body: paras( - 'Everything on this site comes from the Studio at /studio. This article, the authors, the categories, the navigation in the header — all of it is content you can edit.', + 'Everything here is content in Trokky. This article, the authors, the categories, the navigation in the header — all of it can be edited, in the Studio or through the API.', 'Start with Site settings: give the magazine its real name. Then open this article and change the title. Refresh the home page. That is the whole loop.', 'Articles can be drafts. A draft is saved but not shown here; publish it when it is ready. The featured switch decides what leads the home page.' ), @@ -120,7 +120,7 @@ export async function seedSampleContent(core: TrokkyCore, readAsset: SeedAssetRe excerpt: 'Save without publishing, publish when ready, unpublish without deleting.', cover: media(c5), author: 'author-ama', category: 'category-tech', featured: false, publishedAt: daysAgo(6), body: paras( - 'Open this article in Studio and set it back to draft. Refresh this page: it is gone from the site, but nothing was deleted. Publish it again and it returns.', + 'Set this article back to draft, in the Studio or through the API. It disappears from the published content, but nothing was deleted. Publish it again and it returns.', 'The site only ever reads published content. Drafts are yours alone.' ) }) @@ -139,5 +139,5 @@ export async function seedSampleContent(core: TrokkyCore, readAsset: SeedAssetRe await core.saveDocument('document', { id: 'document-guidelines', ...P, title: 'Editorial guidelines', slug: 'editorial-guidelines', summary: 'How we write, and what we will not publish.', file: media(pdfGuide), publishedAt: daysAgo(12) }) await core.saveDocument('page', { id: 'page-about', ...P, title: 'About', slug: 'about', body: paras('This magazine runs on Trokky, a self-hosted CMS, on Cloudflare Workers. The content is in a D1 database and the files in an R2 bucket — both on your own account.', 'Replace this page with who you are.') }) - await core.saveDocument('page', { id: 'page-contact', ...P, title: 'Contact', slug: 'contact', body: paras('Put an email address, a form, or a map here. This is an ordinary page: edit it under Pages in Studio.') }) + await core.saveDocument('page', { id: 'page-contact', ...P, title: 'Contact', slug: 'contact', body: paras('Put an email address, a form, or a map here. This is an ordinary page: edit it like any other page document.') }) } diff --git a/files/content/magazine/src/trokky/structure.ts b/files/content/magazine/src/trokky/structure.ts index 75b33a9..af03033 100644 --- a/files/content/magazine/src/trokky/structure.ts +++ b/files/content/magazine/src/trokky/structure.ts @@ -1,5 +1,6 @@ /** - * How content is arranged in the Studio sidebar. + * How content is arranged: the Studio's sidebar, when there is one, and the document id each + * singleton is opened and first created under, which the API uses too. * * The schema decides what a singleton is; this only decides where things appear and which * document id the singleton uses. diff --git a/test/generate.test.ts b/test/generate.test.ts index 6aec292..fdfcd6c 100644 --- a/test/generate.test.ts +++ b/test/generate.test.ts @@ -122,6 +122,12 @@ describe('an API-only Worker', () => { expect(text(build({ target: 'node', parts: 'api', content }), '.env.example')).not.toContain('open Studio') } expect(text(build({ parts: 'studio', content: 'magazine' }), '.gitignore')).toContain('public/studio/') + // The sample content is shared by every composition: it may mention the Studio, but never + // as the only way in, and never send anyone to a /studio an API-only project lacks. + for (const content of ['magazine', 'conference'] as const) { + const seed = text(build({ parts: 'api', content }), 'src/trokky/seed.ts') + expect(seed).not.toMatch(/href="\/studio"|in Studio\b|dans Studio|editable in Studio|site and the Studio/) + } }) it('depends on neither Studio nor Astro', () => {