create-kitcms 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -2
- package/bin/create.js +5 -0
- package/dist/args.d.ts +15 -0
- package/dist/args.js +72 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +150 -0
- package/dist/scaffold.d.ts +25 -0
- package/dist/scaffold.js +98 -0
- package/dist/wrangler.d.ts +2 -0
- package/dist/wrangler.js +7 -0
- package/package.json +34 -3
- package/templates/blank/.dev.vars.example +1 -0
- package/templates/blank/README.md +39 -0
- package/templates/blank/_gitignore +7 -0
- package/templates/blank/package.json +37 -0
- package/templates/blank/pnpm-workspace.yaml +3 -0
- package/templates/blank/src/app.d.ts +22 -0
- package/templates/blank/src/app.html +11 -0
- package/templates/blank/src/hooks.server.ts +4 -0
- package/templates/blank/src/kitcms.admin.ts +14 -0
- package/templates/blank/src/kitcms.config.ts +32 -0
- package/templates/blank/src/kitcms.rpc.ts +6 -0
- package/templates/blank/src/lib/index.ts +1 -0
- package/templates/blank/src/routes/(kitcms)/admin/[...path]/+page.server.ts +2 -0
- package/templates/blank/src/routes/(kitcms)/admin/[...path]/+page.svelte +9 -0
- package/templates/blank/src/routes/(kitcms)/api/[...path]/+server.ts +2 -0
- package/templates/blank/src/routes/+page.server.ts +7 -0
- package/templates/blank/src/routes/+page.svelte +19 -0
- package/templates/blank/tsconfig.json +11 -0
- package/templates/blank/vite.config.ts +8 -0
- package/templates/blank/wrangler.jsonc +28 -0
- package/templates/website/.dev.vars.example +1 -0
- package/templates/website/README.md +105 -0
- package/templates/website/_gitignore +7 -0
- package/templates/website/package.json +42 -0
- package/templates/website/pnpm-workspace.yaml +3 -0
- package/templates/website/src/app.css +23 -0
- package/templates/website/src/app.d.ts +22 -0
- package/templates/website/src/app.html +11 -0
- package/templates/website/src/hooks.server.ts +4 -0
- package/templates/website/src/kitcms.admin.ts +19 -0
- package/templates/website/src/kitcms.config.ts +269 -0
- package/templates/website/src/kitcms.rpc.ts +6 -0
- package/templates/website/src/kitcms.seed.ts +232 -0
- package/templates/website/src/lib/Img.svelte +62 -0
- package/templates/website/src/lib/Link.svelte +10 -0
- package/templates/website/src/lib/PageView.svelte +30 -0
- package/templates/website/src/lib/PostList.svelte +169 -0
- package/templates/website/src/lib/RichText.svelte +13 -0
- package/templates/website/src/lib/Seo.svelte +31 -0
- package/templates/website/src/lib/blocks/AdminPreview.svelte +59 -0
- package/templates/website/src/lib/blocks/Cta.svelte +86 -0
- package/templates/website/src/lib/blocks/Features.svelte +147 -0
- package/templates/website/src/lib/blocks/Gallery.svelte +122 -0
- package/templates/website/src/lib/blocks/Hero.svelte +151 -0
- package/templates/website/src/lib/blocks/LatestPosts.svelte +36 -0
- package/templates/website/src/lib/blocks/RenderBlocks.svelte +38 -0
- package/templates/website/src/lib/blocks/ResolveMedia.svelte +27 -0
- package/templates/website/src/lib/blocks/RichTextBlock.svelte +47 -0
- package/templates/website/src/lib/blocks/TeamGrid.svelte +159 -0
- package/templates/website/src/lib/blocks/types.ts +47 -0
- package/templates/website/src/lib/content.ts +31 -0
- package/templates/website/src/lib/designs.ts +79 -0
- package/templates/website/src/lib/format.ts +3 -0
- package/templates/website/src/lib/icons.ts +13 -0
- package/templates/website/src/lib/image.ts +29 -0
- package/templates/website/src/lib/index.ts +1 -0
- package/templates/website/src/lib/media.ts +32 -0
- package/templates/website/src/lib/shell/Footer.svelte +146 -0
- package/templates/website/src/lib/shell/Header.svelte +121 -0
- package/templates/website/src/lib/shell/MobileMenu.svelte +142 -0
- package/templates/website/src/lib/shell/shell.ts +52 -0
- package/templates/website/src/lib/site.css +329 -0
- package/templates/website/src/routes/(kitcms)/admin/[...path]/+page.server.ts +2 -0
- package/templates/website/src/routes/(kitcms)/admin/[...path]/+page.svelte +9 -0
- package/templates/website/src/routes/(kitcms)/api/[...path]/+server.ts +2 -0
- package/templates/website/src/routes/(site)/+error.svelte +23 -0
- package/templates/website/src/routes/(site)/+layout.server.ts +12 -0
- package/templates/website/src/routes/(site)/+layout.svelte +63 -0
- package/templates/website/src/routes/(site)/+page.server.ts +7 -0
- package/templates/website/src/routes/(site)/+page.svelte +33 -0
- package/templates/website/src/routes/(site)/[slug]/+page.server.ts +11 -0
- package/templates/website/src/routes/(site)/[slug]/+page.svelte +9 -0
- package/templates/website/src/routes/(site)/blog/+page.server.ts +20 -0
- package/templates/website/src/routes/(site)/blog/+page.svelte +66 -0
- package/templates/website/src/routes/(site)/blog/[slug]/+page.server.ts +11 -0
- package/templates/website/src/routes/(site)/blog/[slug]/+page.svelte +231 -0
- package/templates/website/src/routes/(site)/legal/[slug]/+page.server.ts +8 -0
- package/templates/website/src/routes/(site)/legal/[slug]/+page.svelte +23 -0
- package/templates/website/tsconfig.json +11 -0
- package/templates/website/vite.config.ts +8 -0
- package/templates/website/wrangler.jsonc +28 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { block, collection, defineConfig, fields as f, global } from '@kitcms/core';
|
|
2
|
+
import { designOptions, isHex, type PageType } from '#lib/designs.ts';
|
|
3
|
+
import { ICONS } from '#lib/icons.ts';
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------------------------
|
|
6
|
+
// Designs. The registry in `src/lib/designs.ts` lists every page type and its designs; the
|
|
7
|
+
// selects below are built from it, so a new design appears in the admin without touching this file.
|
|
8
|
+
// ---------------------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
const DESIGN_HINT =
|
|
11
|
+
'Leave empty to use the site setting (Site settings > Design). Pick one to override it for this page only.';
|
|
12
|
+
/** Per-page override. Select values can't be empty: unset means "use the site setting". */
|
|
13
|
+
const pageDesign = (type: PageType) =>
|
|
14
|
+
f.select({
|
|
15
|
+
label: 'Design',
|
|
16
|
+
options: designOptions(type),
|
|
17
|
+
admin: { position: 'sidebar', description: DESIGN_HINT },
|
|
18
|
+
});
|
|
19
|
+
/** Site-wide default for a page type (the type's first design until changed). */
|
|
20
|
+
const siteDesign = (type: PageType) =>
|
|
21
|
+
f.select({ options: designOptions(type), defaultValue: designOptions(type)[0]!.value });
|
|
22
|
+
/** Optional brand colour: empty or `#rgb` / `#rrggbb` (it ends up in a CSS variable, validated again at render). */
|
|
23
|
+
const hex = (label: string, placeholder: string) =>
|
|
24
|
+
f.text({
|
|
25
|
+
label,
|
|
26
|
+
maxLength: 7,
|
|
27
|
+
validate: (value) => !value || isHex(value) || 'Use a hex colour such as #1f4e79.',
|
|
28
|
+
admin: { placeholder, description: 'Empty uses the default.' },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------------------------
|
|
32
|
+
// Blocks. Each one has a Svelte component of the same name in `src/lib/blocks/`, used by the
|
|
33
|
+
// public site (`RenderBlocks.svelte`) and, through `src/kitcms.admin.ts`, as the live preview.
|
|
34
|
+
// ---------------------------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
const Hero = block({
|
|
37
|
+
slug: 'hero',
|
|
38
|
+
fields: {
|
|
39
|
+
heading: f.text({ required: true }),
|
|
40
|
+
subheading: f.textarea(),
|
|
41
|
+
image: f.upload({ relationTo: 'media' }),
|
|
42
|
+
ctaLabel: f.text({ label: 'Button label' }),
|
|
43
|
+
ctaHref: f.text({ label: 'Button link', admin: { placeholder: '/contact or https://...' } }),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const RichText = block({
|
|
48
|
+
slug: 'richText',
|
|
49
|
+
labels: { singular: 'Rich text', plural: 'Rich text' },
|
|
50
|
+
fields: { body: f.richText() },
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const Features = block({
|
|
54
|
+
slug: 'features',
|
|
55
|
+
fields: {
|
|
56
|
+
title: f.text(),
|
|
57
|
+
items: f.array({
|
|
58
|
+
maxRows: 12,
|
|
59
|
+
labels: { singular: 'Feature', plural: 'Features' },
|
|
60
|
+
fields: {
|
|
61
|
+
title: f.text({ required: true }),
|
|
62
|
+
text: f.textarea(),
|
|
63
|
+
icon: f.select({ options: ICONS }),
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const Gallery = block({
|
|
70
|
+
slug: 'gallery',
|
|
71
|
+
fields: { images: f.upload({ relationTo: 'media', hasMany: true }) },
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const Cta = block({
|
|
75
|
+
slug: 'cta',
|
|
76
|
+
labels: { singular: 'Call to action', plural: 'Calls to action' },
|
|
77
|
+
fields: {
|
|
78
|
+
heading: f.text({ required: true }),
|
|
79
|
+
text: f.textarea(),
|
|
80
|
+
buttonLabel: f.text({ required: true }),
|
|
81
|
+
buttonHref: f.text({ required: true, admin: { placeholder: '/contact or https://...' } }),
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const TeamGrid = block({
|
|
86
|
+
slug: 'teamGrid',
|
|
87
|
+
labels: { singular: 'Team grid', plural: 'Team grids' },
|
|
88
|
+
// Renders the `team` collection, in the order editors set there.
|
|
89
|
+
fields: { title: f.text() },
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const LatestPosts = block({
|
|
93
|
+
slug: 'latestPosts',
|
|
94
|
+
labels: { singular: 'Latest posts', plural: 'Latest posts' },
|
|
95
|
+
fields: {
|
|
96
|
+
title: f.text(),
|
|
97
|
+
count: f.number({ integer: true, min: 1, max: 12, defaultValue: 3 }),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const pageBlocks = [Hero, RichText, Features, Gallery, Cta, TeamGrid, LatestPosts] as const;
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------------------------
|
|
104
|
+
// Config
|
|
105
|
+
// ---------------------------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
export default defineConfig({
|
|
108
|
+
admin: { title: '__APP_NAME__' },
|
|
109
|
+
// Edge cache for anonymous published reads. Needs a custom domain: the Workers Cache API does
|
|
110
|
+
// nothing on *.workers.dev. Writes clear it in the writer's region at once; other regions
|
|
111
|
+
// serve a cached read for up to `ttl` seconds.
|
|
112
|
+
cache: { ttl: 60 },
|
|
113
|
+
collections: [
|
|
114
|
+
collection({
|
|
115
|
+
slug: 'media',
|
|
116
|
+
upload: { mimeTypes: ['image/*', 'application/pdf'] },
|
|
117
|
+
access: { read: () => true },
|
|
118
|
+
fields: { alt: f.text({ label: 'Alt text' }) },
|
|
119
|
+
}),
|
|
120
|
+
collection({
|
|
121
|
+
slug: 'pages',
|
|
122
|
+
// Drafts + autosave: anonymous reads only ever see published pages.
|
|
123
|
+
versions: { drafts: { autosave: true } },
|
|
124
|
+
admin: { useAsTitle: 'title', defaultColumns: ['title', 'slug', '_status', 'updatedAt'] },
|
|
125
|
+
access: { read: () => true },
|
|
126
|
+
fields: {
|
|
127
|
+
title: f.text({ required: true }),
|
|
128
|
+
// `home` is the page served at `/`. `blog` and `legal` are taken by the routes.
|
|
129
|
+
slug: f.slug({ from: 'title', unique: true, admin: { position: 'sidebar' } }),
|
|
130
|
+
// The home page (slug `home`) uses the `home` designs, every other page the `page` designs.
|
|
131
|
+
design: pageDesign('page'),
|
|
132
|
+
content: f.tabs({
|
|
133
|
+
tabs: [
|
|
134
|
+
{ label: 'Content', fields: { sections: f.blocks({ blocks: pageBlocks }) } },
|
|
135
|
+
{
|
|
136
|
+
label: 'SEO',
|
|
137
|
+
fields: {
|
|
138
|
+
seo: f.group({
|
|
139
|
+
fields: {
|
|
140
|
+
metaTitle: f.text({ maxLength: 70 }),
|
|
141
|
+
metaDescription: f.textarea({ maxLength: 160 }),
|
|
142
|
+
image: f.upload({ relationTo: 'media', label: 'Social image' }),
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
collection({
|
|
152
|
+
slug: 'posts',
|
|
153
|
+
versions: { drafts: true },
|
|
154
|
+
admin: { useAsTitle: 'title', defaultColumns: ['title', 'slug', 'publishedAt', '_status'] },
|
|
155
|
+
defaultSort: '-publishedAt',
|
|
156
|
+
access: { read: () => true },
|
|
157
|
+
fields: {
|
|
158
|
+
title: f.text({ required: true }),
|
|
159
|
+
slug: f.slug({ from: 'title', unique: true, admin: { position: 'sidebar' } }),
|
|
160
|
+
publishedAt: f.date({ admin: { position: 'sidebar' } }),
|
|
161
|
+
design: pageDesign('post'),
|
|
162
|
+
tags: f.relationship({ relationTo: 'tags', hasMany: true, admin: { position: 'sidebar' } }),
|
|
163
|
+
excerpt: f.textarea({ maxLength: 300 }),
|
|
164
|
+
cover: f.upload({ relationTo: 'media' }),
|
|
165
|
+
body: f.richText(),
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
collection({
|
|
169
|
+
slug: 'tags',
|
|
170
|
+
admin: { useAsTitle: 'name' },
|
|
171
|
+
access: { read: () => true },
|
|
172
|
+
fields: {
|
|
173
|
+
name: f.text({ required: true }),
|
|
174
|
+
slug: f.slug({ from: 'name', unique: true }),
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
collection({
|
|
178
|
+
slug: 'team',
|
|
179
|
+
// Drag to reorder in the admin list; `find` returns members in that order.
|
|
180
|
+
orderable: true,
|
|
181
|
+
admin: { useAsTitle: 'name', defaultColumns: ['name', 'role'] },
|
|
182
|
+
access: { read: () => true },
|
|
183
|
+
fields: {
|
|
184
|
+
name: f.text({ required: true }),
|
|
185
|
+
role: f.text(),
|
|
186
|
+
photo: f.upload({ relationTo: 'media' }),
|
|
187
|
+
bio: f.textarea(),
|
|
188
|
+
},
|
|
189
|
+
}),
|
|
190
|
+
collection({
|
|
191
|
+
slug: 'legal',
|
|
192
|
+
// A fixed set of documents: editors can edit them but not create or delete them.
|
|
193
|
+
// `pnpm db:seed` creates them.
|
|
194
|
+
admin: { locked: true, useAsTitle: 'title', defaultColumns: ['title', 'slug', 'updatedAt'] },
|
|
195
|
+
access: { read: () => true },
|
|
196
|
+
fields: {
|
|
197
|
+
title: f.text({ required: true }),
|
|
198
|
+
slug: f.slug({ from: 'title', unique: true, admin: { position: 'sidebar' } }),
|
|
199
|
+
body: f.richText(),
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
202
|
+
],
|
|
203
|
+
globals: [
|
|
204
|
+
global({
|
|
205
|
+
slug: 'site',
|
|
206
|
+
label: 'Site settings',
|
|
207
|
+
versions: { drafts: true },
|
|
208
|
+
access: { read: () => true },
|
|
209
|
+
fields: {
|
|
210
|
+
settings: f.tabs({
|
|
211
|
+
tabs: [
|
|
212
|
+
{
|
|
213
|
+
label: 'General',
|
|
214
|
+
fields: {
|
|
215
|
+
siteName: f.text({ required: true }),
|
|
216
|
+
tagline: f.textarea(),
|
|
217
|
+
logo: f.upload({ relationTo: 'media' }),
|
|
218
|
+
// Each item links to a page or, for routes that are not pages (`/blog`), to a path.
|
|
219
|
+
nav: f.array({
|
|
220
|
+
labels: { singular: 'Link', plural: 'Navigation' },
|
|
221
|
+
fields: {
|
|
222
|
+
label: f.text({ required: true }),
|
|
223
|
+
page: f.relationship({ relationTo: 'pages' }),
|
|
224
|
+
href: f.text({ admin: { description: 'Used when no page is chosen, e.g. /blog' } }),
|
|
225
|
+
},
|
|
226
|
+
}),
|
|
227
|
+
footer: f.group({
|
|
228
|
+
fields: {
|
|
229
|
+
text: f.textarea(),
|
|
230
|
+
social: f.array({
|
|
231
|
+
labels: { singular: 'Link', plural: 'Social links' },
|
|
232
|
+
fields: { label: f.text({ required: true }), url: f.text({ required: true }) },
|
|
233
|
+
}),
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
label: 'Design',
|
|
240
|
+
description:
|
|
241
|
+
'One design per page type. A page or post can override it in its sidebar. All designs share the same colours and fonts.',
|
|
242
|
+
fields: {
|
|
243
|
+
design: f.group({
|
|
244
|
+
fields: {
|
|
245
|
+
header: siteDesign('header'),
|
|
246
|
+
footer: siteDesign('footer'),
|
|
247
|
+
home: siteDesign('home'),
|
|
248
|
+
page: siteDesign('page'),
|
|
249
|
+
blog: siteDesign('blog'),
|
|
250
|
+
post: siteDesign('post'),
|
|
251
|
+
},
|
|
252
|
+
}),
|
|
253
|
+
// Set all three together: surface, muted text and lines are derived from them.
|
|
254
|
+
theme: f.group({
|
|
255
|
+
label: 'Colours',
|
|
256
|
+
fields: {
|
|
257
|
+
accent: hex('Accent (buttons, links)', '#1f4e79'),
|
|
258
|
+
background: hex('Background', '#f7f6f3'),
|
|
259
|
+
text: hex('Text', '#17181a'),
|
|
260
|
+
},
|
|
261
|
+
}),
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
}),
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
],
|
|
269
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// GENERATED by kitcms. The Service Binding entrypoint other Workers bind to (entrypoint "KitcmsRPC").
|
|
2
|
+
// Must stay a class declaration: wrangler/workerd detect entrypoints by exported classes.
|
|
3
|
+
import { createKitcmsRPC } from '@kitcms/core/rpc';
|
|
4
|
+
import config from './kitcms.config';
|
|
5
|
+
|
|
6
|
+
export class KitcmsRPC extends createKitcmsRPC(config) {}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// Example content: `pnpm db:seed` (local D1) or `pnpm db:seed:remote`.
|
|
2
|
+
// Idempotent: every document is created only when it does not exist yet, so running it again never
|
|
3
|
+
// overwrites what editors changed. No media is seeded (blocks handle missing images); upload
|
|
4
|
+
// images in the admin and attach them.
|
|
5
|
+
import { defineSeed, type RichTextDoc, type RichTextNode } from '@kitcms/core';
|
|
6
|
+
|
|
7
|
+
// ---- Tiptap JSON helpers ----------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
const text = (value: string, marks?: RichTextNode['marks']): RichTextNode => ({
|
|
10
|
+
type: 'text',
|
|
11
|
+
text: value,
|
|
12
|
+
...(marks ? { marks } : {}),
|
|
13
|
+
});
|
|
14
|
+
const p = (...content: (string | RichTextNode)[]): RichTextNode => ({
|
|
15
|
+
type: 'paragraph',
|
|
16
|
+
content: content.map((c) => (typeof c === 'string' ? text(c) : c)),
|
|
17
|
+
});
|
|
18
|
+
const h = (level: number, value: string): RichTextNode => ({
|
|
19
|
+
type: 'heading',
|
|
20
|
+
attrs: { level },
|
|
21
|
+
content: [text(value)],
|
|
22
|
+
});
|
|
23
|
+
const ul = (...items: string[]): RichTextNode => ({
|
|
24
|
+
type: 'bulletList',
|
|
25
|
+
content: items.map((i) => ({ type: 'listItem', content: [p(i)] })),
|
|
26
|
+
});
|
|
27
|
+
const doc = (...content: RichTextNode[]): RichTextDoc => ({ type: 'doc', content });
|
|
28
|
+
const bold = (value: string) => text(value, [{ type: 'bold' }]);
|
|
29
|
+
|
|
30
|
+
// ---- Seed -------------------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
export default defineSeed(async ({ ensure, ensureGlobal, log }) => {
|
|
33
|
+
const bySlug = (slug: string) => ({ slug: { equals: slug } });
|
|
34
|
+
|
|
35
|
+
// Tags
|
|
36
|
+
const news = await ensure('tags', {
|
|
37
|
+
where: bySlug('news'),
|
|
38
|
+
data: { name: 'News', slug: 'news' },
|
|
39
|
+
});
|
|
40
|
+
const guides = await ensure('tags', {
|
|
41
|
+
where: bySlug('guides'),
|
|
42
|
+
data: { name: 'Guides', slug: 'guides' },
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Posts (published: the seed creates them without `draft`)
|
|
46
|
+
const posts = [
|
|
47
|
+
{
|
|
48
|
+
slug: 'welcome-to-our-new-site',
|
|
49
|
+
title: 'Welcome to our new site',
|
|
50
|
+
publishedAt: '2026-11-10T09:00:00.000Z',
|
|
51
|
+
tags: [news.id],
|
|
52
|
+
excerpt: 'We rebuilt our website. Here is what is new and where to find everything.',
|
|
53
|
+
body: doc(
|
|
54
|
+
p(
|
|
55
|
+
'We rebuilt our website to make it faster, simpler and easier for us to keep up to date.',
|
|
56
|
+
),
|
|
57
|
+
h(2, 'What is new'),
|
|
58
|
+
ul(
|
|
59
|
+
'A new blog, where we will share news and guides',
|
|
60
|
+
'A page for the team behind the work',
|
|
61
|
+
'Clearer contact details on every page',
|
|
62
|
+
),
|
|
63
|
+
p('Thank you for visiting. ', bold('Tell us what you think.')),
|
|
64
|
+
),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
slug: 'how-we-work',
|
|
68
|
+
title: 'How we work',
|
|
69
|
+
publishedAt: '2026-11-03T09:00:00.000Z',
|
|
70
|
+
tags: [guides.id],
|
|
71
|
+
excerpt: 'A short look at our process, from the first conversation to delivery.',
|
|
72
|
+
body: doc(
|
|
73
|
+
p('Every project starts with a conversation. We listen first, then propose a plan.'),
|
|
74
|
+
h(2, 'Our process'),
|
|
75
|
+
ul(
|
|
76
|
+
'Discover: we learn what you need',
|
|
77
|
+
'Design: we agree on the approach',
|
|
78
|
+
'Deliver: we ship in small steps',
|
|
79
|
+
),
|
|
80
|
+
p('Questions? We are happy to talk it through.'),
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
slug: 'three-tips-for-a-small-website',
|
|
85
|
+
title: 'Three tips for a small website',
|
|
86
|
+
publishedAt: '2026-10-27T09:00:00.000Z',
|
|
87
|
+
tags: [guides.id, news.id],
|
|
88
|
+
excerpt: 'Keep it fast, keep it clear, keep it current.',
|
|
89
|
+
body: doc(
|
|
90
|
+
p('A small website does not need to be complicated. Three things matter most.'),
|
|
91
|
+
ul(
|
|
92
|
+
'Keep it fast: small images, few scripts',
|
|
93
|
+
'Keep it clear: one goal per page',
|
|
94
|
+
'Keep it current: update it when things change',
|
|
95
|
+
),
|
|
96
|
+
{ type: 'blockquote', content: [p('Good websites are mostly good editing.')] },
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
for (const post of posts) await ensure('posts', { where: bySlug(post.slug), data: post });
|
|
101
|
+
|
|
102
|
+
// Team (in this order; editors can drag to reorder in the admin)
|
|
103
|
+
for (const [name, role, bio] of [
|
|
104
|
+
[
|
|
105
|
+
'Alex Morgan',
|
|
106
|
+
'Founder',
|
|
107
|
+
'Starts every project with a conversation and ends it with a handover.',
|
|
108
|
+
],
|
|
109
|
+
['Sam Rivera', 'Design', 'Turns rough ideas into clear, usable pages.'],
|
|
110
|
+
['Jordan Lee', 'Engineering', 'Keeps everything fast, secure and boring in the best way.'],
|
|
111
|
+
] as const) {
|
|
112
|
+
await ensure('team', { where: { name: { equals: name } }, data: { name, role, bio } });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Legal pages (the collection is locked: only the seed can create them)
|
|
116
|
+
await ensure('legal', {
|
|
117
|
+
where: bySlug('privacy'),
|
|
118
|
+
data: {
|
|
119
|
+
title: 'Privacy',
|
|
120
|
+
slug: 'privacy',
|
|
121
|
+
body: doc(
|
|
122
|
+
p('This is an example privacy policy. Replace it with your own text in the admin.'),
|
|
123
|
+
h(2, 'What we collect'),
|
|
124
|
+
p('Describe the personal data you collect, why you collect it and how long you keep it.'),
|
|
125
|
+
h(2, 'Contact'),
|
|
126
|
+
p('Tell visitors how to reach you with privacy questions.'),
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
await ensure('legal', {
|
|
131
|
+
where: bySlug('terms'),
|
|
132
|
+
data: {
|
|
133
|
+
title: 'Terms',
|
|
134
|
+
slug: 'terms',
|
|
135
|
+
body: doc(
|
|
136
|
+
p('These are example terms. Replace them with your own text in the admin.'),
|
|
137
|
+
h(2, 'Using this site'),
|
|
138
|
+
p('Describe the rules for using your site and services.'),
|
|
139
|
+
),
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Pages
|
|
144
|
+
const home = await ensure('pages', {
|
|
145
|
+
where: bySlug('home'),
|
|
146
|
+
data: {
|
|
147
|
+
title: 'Home',
|
|
148
|
+
slug: 'home',
|
|
149
|
+
sections: [
|
|
150
|
+
{
|
|
151
|
+
blockType: 'hero',
|
|
152
|
+
heading: 'A small studio for careful work',
|
|
153
|
+
subheading: 'We help small businesses look good online, without the complexity.',
|
|
154
|
+
ctaLabel: 'Get in touch',
|
|
155
|
+
ctaHref: '/about',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
blockType: 'features',
|
|
159
|
+
title: 'Why work with us',
|
|
160
|
+
items: [
|
|
161
|
+
{
|
|
162
|
+
title: 'Clear and simple',
|
|
163
|
+
text: 'No jargon. You always know what happens next.',
|
|
164
|
+
icon: 'chat',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title: 'Built to last',
|
|
168
|
+
text: 'Fast, accessible sites that are easy to keep up to date.',
|
|
169
|
+
icon: 'shield',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
title: 'On time',
|
|
173
|
+
text: 'Small steps, regular updates, no surprises.',
|
|
174
|
+
icon: 'clock',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
{ blockType: 'latestPosts', title: 'From the blog', count: 3 },
|
|
179
|
+
{
|
|
180
|
+
blockType: 'cta',
|
|
181
|
+
heading: 'Ready to start?',
|
|
182
|
+
text: 'Tell us about your project. We reply within two working days.',
|
|
183
|
+
buttonLabel: 'Meet the team',
|
|
184
|
+
buttonHref: '/about',
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
seo: { metaTitle: 'Home', metaDescription: 'A small studio for careful work.' },
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
const about = await ensure('pages', {
|
|
191
|
+
where: bySlug('about'),
|
|
192
|
+
data: {
|
|
193
|
+
title: 'About',
|
|
194
|
+
slug: 'about',
|
|
195
|
+
sections: [
|
|
196
|
+
{
|
|
197
|
+
blockType: 'richText',
|
|
198
|
+
body: doc(
|
|
199
|
+
h(1, 'About us'),
|
|
200
|
+
p('We are a small team that believes good work comes from listening first.'),
|
|
201
|
+
p(
|
|
202
|
+
'Since the beginning we have worked with local businesses, ',
|
|
203
|
+
bold('one project at a time'),
|
|
204
|
+
'.',
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
},
|
|
208
|
+
{ blockType: 'teamGrid', title: 'The team' },
|
|
209
|
+
],
|
|
210
|
+
seo: { metaTitle: 'About', metaDescription: 'Who we are and how we work.' },
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Site settings (a draft-enabled global: this publishes it)
|
|
215
|
+
await ensureGlobal('site', {
|
|
216
|
+
siteName: 'My site',
|
|
217
|
+
tagline: 'A small studio for careful work.',
|
|
218
|
+
nav: [
|
|
219
|
+
{ label: 'Home', page: home.id },
|
|
220
|
+
{ label: 'About', page: about.id },
|
|
221
|
+
{ label: 'Blog', href: '/blog' },
|
|
222
|
+
],
|
|
223
|
+
footer: {
|
|
224
|
+
text: 'Built with kitcms on Cloudflare Workers.',
|
|
225
|
+
social: [
|
|
226
|
+
{ label: 'GitHub', url: 'https://github.com' },
|
|
227
|
+
{ label: 'Email', url: 'mailto:hello@example.com' },
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
log('Seed done. Open /admin to edit it, and replace the example text.');
|
|
232
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { dev } from '$app/env';
|
|
3
|
+
import { page } from '$app/state';
|
|
4
|
+
import { imageUrl } from './image';
|
|
5
|
+
import type { Media } from './media';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
media: Media | null;
|
|
9
|
+
/** Widths (px) offered in `srcset`. The middle one is the fallback `src`. */
|
|
10
|
+
widths?: number[];
|
|
11
|
+
sizes?: string;
|
|
12
|
+
/** Crop to this width / height ratio (`cover`). */
|
|
13
|
+
ratio?: number;
|
|
14
|
+
/** Fill the parent box (`cover`): for backgrounds. The parent sets the size. */
|
|
15
|
+
fill?: boolean;
|
|
16
|
+
eager?: boolean;
|
|
17
|
+
/** Overrides the media's alt text (`""` marks a decorative picture). */
|
|
18
|
+
alt?: string;
|
|
19
|
+
class?: string;
|
|
20
|
+
}
|
|
21
|
+
let {
|
|
22
|
+
media,
|
|
23
|
+
widths = [480, 960, 1600],
|
|
24
|
+
sizes = '100vw',
|
|
25
|
+
ratio,
|
|
26
|
+
fill = false,
|
|
27
|
+
eager = false,
|
|
28
|
+
alt,
|
|
29
|
+
class: className,
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
// Transformations need a zone: not in dev and not on *.workers.dev.
|
|
33
|
+
const enabled = $derived(!dev && !page.url.hostname.endsWith('.workers.dev'));
|
|
34
|
+
const fallback = $derived(widths[Math.floor(widths.length / 2)] ?? 960);
|
|
35
|
+
const build = (w: number) =>
|
|
36
|
+
media
|
|
37
|
+
? imageUrl(
|
|
38
|
+
media.url,
|
|
39
|
+
{ width: w, height: ratio ? w / ratio : undefined, fit: ratio ? 'cover' : 'scale-down' },
|
|
40
|
+
enabled,
|
|
41
|
+
)
|
|
42
|
+
: '';
|
|
43
|
+
const srcset = $derived(enabled ? widths.map((w) => `${build(w)} ${w}w`).join(', ') : undefined);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
{#if media}
|
|
47
|
+
<img
|
|
48
|
+
class={className}
|
|
49
|
+
src={build(fallback)}
|
|
50
|
+
{srcset}
|
|
51
|
+
{sizes}
|
|
52
|
+
alt={alt ?? media.alt ?? ''}
|
|
53
|
+
width={media.width ?? undefined}
|
|
54
|
+
height={media.height ?? undefined}
|
|
55
|
+
loading={eager ? 'eager' : 'lazy'}
|
|
56
|
+
decoding="async"
|
|
57
|
+
style:aspect-ratio={fill ? undefined : ratio}
|
|
58
|
+
style:width={ratio || fill ? '100%' : undefined}
|
|
59
|
+
style:height={fill ? '100%' : undefined}
|
|
60
|
+
style:object-fit={ratio || fill ? 'cover' : undefined}
|
|
61
|
+
/>
|
|
62
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
// For hrefs that come from the CMS (editors type them), which can't be typed routes.
|
|
5
|
+
let { href, class: className, children, ...rest }: HTMLAnchorAttributes = $props();
|
|
6
|
+
const external = $derived(/^https?:\/\//i.test(href ?? ''));
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
|
10
|
+
<a {href} class={className} rel={external ? 'noopener' : undefined} {...rest}>{@render children?.()}</a>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import RenderBlocks from './blocks/RenderBlocks.svelte';
|
|
3
|
+
import type { BlockExtras, PageBlock } from './blocks/types';
|
|
4
|
+
import type { DesignId } from './designs';
|
|
5
|
+
import { asMedia } from './media';
|
|
6
|
+
import Seo from './Seo.svelte';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
page: {
|
|
10
|
+
title: string;
|
|
11
|
+
seo?: { metaTitle?: string | null; metaDescription?: string | null; image?: unknown } | null;
|
|
12
|
+
};
|
|
13
|
+
blocks: PageBlock[];
|
|
14
|
+
extras: BlockExtras;
|
|
15
|
+
/** The resolved design for this page (see `designs.ts`). */
|
|
16
|
+
design: DesignId;
|
|
17
|
+
siteName?: string | null;
|
|
18
|
+
tagline?: string | null;
|
|
19
|
+
}
|
|
20
|
+
let { page, blocks, extras, design, siteName, tagline }: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Seo
|
|
24
|
+
title={page.seo?.metaTitle || page.title}
|
|
25
|
+
description={page.seo?.metaDescription || tagline}
|
|
26
|
+
image={asMedia(page.seo?.image)}
|
|
27
|
+
{siteName}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<RenderBlocks {blocks} {extras} {design} />
|