create-kywi-app 0.28.0 → 0.30.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.
@@ -532,6 +532,16 @@ raw JSON textarea — developer territory. A "three stats" module with `stats: {
532
532
  type: 'json' }` has taken the copy away from the owner; the same module with
533
533
  `stat1Value` / `stat1Label` … as `text` props hasn't.
534
534
 
535
+ **Organize a long props panel.** Past ~6 props the panel is one long column,
536
+ so give repeated sets and secondary settings a `group: 'tile1'` (drawn as a
537
+ collapsible section where its first prop is declared), name the sections with
538
+ `propGroups: { tile1: { label: 'Tile 1', description?, collapsed? } }` on the
539
+ module, and move format hints out of labels into `help: '…'` (one line under
540
+ the field). Inside a group, drop the item prefix from labels (`'Image'`, not
541
+ `'Tile 2: Image'`). Keep primary copy ungrouped at the top; collapse
542
+ rarely-touched sections. Presentation only — storage and rendering are
543
+ unchanged.
544
+
535
545
  **Anchor every copy prop in the component.** The front-of-site editor edits
536
546
  one prop at a time, in the element that renders it. Mark that element with
537
547
  `useInlinePropAnchor()` from `@kywi-software/core/layout` —
@@ -69,6 +69,30 @@ Two rules that decide whether the module is really editable:
69
69
  falls back to the props rail. (Unanchored, only a module with a single text
70
70
  prop, declared first, edits in place.)
71
71
 
72
+ **Organize the panel when a module has more than ~6 props.** The props panel
73
+ draws fields top to bottom in declaration order; past a handful it becomes one
74
+ long, undifferentiated column. Three presentation-only tools (storage,
75
+ rendering and the API are unaffected):
76
+
77
+ - **`group: 'key'`** on a prop puts it in a collapsible section headed by that
78
+ group. A section sits where its first prop is declared. Group every repeated
79
+ set (`tile1*` → `'tile1'`, `stat2*` → `'stat2'`) and secondary settings
80
+ (`'layout'`, `'advanced'`). Leave the module's primary copy (heading, body)
81
+ ungrouped at the top — that is what the owner opens the panel to change.
82
+ - **`propGroups: { key: { label, description?, collapsed? } }`** on the module
83
+ names each section. Start rarely-touched sections (`advanced`, layout knobs,
84
+ the 2nd and later repeated items when there are many) `collapsed: true`, and
85
+ keep the first repeated item open so the owner sees the shape.
86
+ - **`help: '…'`** on a prop is one line of guidance under the field. Keep
87
+ `label` short — `'Crop'`, not `'Crop (CSS object-position, e.g. top left)'` —
88
+ and move the format hint to `help`. Inside a group the section heading
89
+ already says which item it is, so labels drop the prefix: `'Image'`, not
90
+ `'Tile 2: Image'`.
91
+
92
+ Rules of thumb: no group for a module with ≤ 6 props; never a group of one;
93
+ group names are nouns the owner recognizes on the page (`Tile 1`, `Pricing
94
+ card`), never prop-name jargon.
95
+
72
96
  ### 3. Register it — `defineModule` in `kywi.config.ts`
73
97
 
74
98
  ```ts
@@ -97,7 +121,15 @@ export default defineKywiConfig({
97
121
  defaultValue: 'split',
98
122
  }, // closed choice = real dropdown
99
123
  reverse: { type: 'boolean', label: 'Image on the left', defaultValue: false },
124
+ // Secondary knobs in their own section, collapsed (see step 2).
125
+ imageCrop: {
126
+ type: 'text',
127
+ label: 'Image crop',
128
+ help: 'CSS object-position, e.g. "top left" or "50% 30%"',
129
+ group: 'advanced',
130
+ },
100
131
  },
132
+ propGroups: { advanced: { label: 'Advanced', collapsed: true } },
101
133
  }),
102
134
  ],
103
135
  })
@@ -178,11 +210,13 @@ entry named after a built-in replaces it.
178
210
  1. Restart the dev server (config changes need a restart).
179
211
  2. Open the layout editor: the module appears in the palette under its
180
212
  `category`, with its `label`.
181
- 3. Place it, fill every prop from the props panel, save — it renders in the
213
+ 3. Select it: the props panel shows the primary copy first, then one section
214
+ per `group`, with the headings and collapsed state you declared.
215
+ 4. Fill every prop from the props panel, save — it renders in the
182
216
  canvas (not "Unknown module") and on the public page.
183
- 4. Open the public page as a signed-in admin → **Edit this page**: the first
217
+ 5. Open the public page as a signed-in admin → **Edit this page**: the first
184
218
  text prop is editable by typing on the page.
185
- 5. Load the page with JavaScript disabled: the content is all there.
219
+ 6. Load the page with JavaScript disabled: the content is all there.
186
220
 
187
221
  ### 8. Handover note
188
222
 
package/lib/templates.mjs CHANGED
@@ -409,10 +409,19 @@ function nextConfig(a) {
409
409
  * - serverExternalPackages: core's server deps (sharp, drizzle, postgres, …)
410
410
  * stay server-side and out of the client bundle.
411
411
  *
412
+ * - withKywi: core's \`beforeFiles\` rewrite that completes
413
+ * \`Accept: text/markdown\` on page URLs. The middleware
414
+ * marks such a request; this rewrite, which (unlike the
415
+ * middleware) still sees Next's RSC headers, sends it to
416
+ * the page's Markdown copy and lets client navigations
417
+ * through. Without it page URLs always answer HTML.
418
+ *
412
419
  * Note: core sanitizes all CMS HTML itself with a DOM-free sanitizer
413
420
  * (sanitize-html), so there is no jsdom-based sanitizer to work around and no
414
421
  * client-side sanitizer stub to wire up here.
415
422
  */
423
+ import { withKywi } from '@kywi-software/core/next/config'
424
+
416
425
  /** @type {import('next').NextConfig} */
417
426
  const nextConfig = {
418
427
  transpilePackages: ['@kywi-software/core'],
@@ -434,7 +443,7 @@ const nextConfig = {
434
443
  },
435
444
  }
436
445
 
437
- export default nextConfig
446
+ export default withKywi(nextConfig)
438
447
  `
439
448
  }
440
449
 
package/lib/upgrade.mjs CHANGED
@@ -243,7 +243,7 @@ export function planUpgrade(projectDir, { force = false, dryRun = false } = {})
243
243
  // ever cause a write or change the exit code.
244
244
  plan.warns.push(...danglingImportWarns(projectDir, plan, expectedFor('runtime', RENDER_LANDMARK_PATHS.runtime)))
245
245
  if (wanted.kywiJs) plan.warns.push(...kywiJsWarns(projectDir))
246
- if (wanted.middleware) plan.warns.push(...nodeMiddlewareWarns(projectDir))
246
+ if (wanted.middleware) plan.warns.push(...nodeMiddlewareWarns(projectDir), ...withKywiWarns(projectDir))
247
247
  const installedCore = installedCoreVersion(projectDir)
248
248
  for (const { path, artifact, version } of scanEjectedArtifacts(projectDir)) {
249
249
  if (installedCore === null || version === installedCore) continue
@@ -410,6 +410,31 @@ function indexingCarryOver(envText) {
410
410
  )
411
411
  }
412
412
 
413
+ /**
414
+ * Since 0.29.0 `Accept: text/markdown` on a page URL needs the project's
415
+ * `next.config` wrapped with core's `withKywi`: the middleware only marks the
416
+ * request, and that config's `beforeFiles` rewrite completes it. `upgrade`
417
+ * never edits next.config, so a config that never calls `withKywi(` is a
418
+ * warn (`.md` addresses keep working either way).
419
+ * @returns {string[]}
420
+ */
421
+ function withKywiWarns(projectDir) {
422
+ for (const name of ['next.config.mjs', 'next.config.js', 'next.config.ts', 'next.config.cjs', 'next.config.mts']) {
423
+ let text
424
+ try {
425
+ text = readFileSync(join(projectDir, name), 'utf8')
426
+ } catch {
427
+ continue
428
+ }
429
+ if (/\bwithKywi\s*\(/.test(text)) return []
430
+ return [
431
+ `${name} does not use withKywi, so Accept: text/markdown on page URLs answers HTML (.md addresses still work) — ` +
432
+ `import { withKywi } from '@kywi-software/core/next/config' and export default withKywi(nextConfig)`,
433
+ ]
434
+ }
435
+ return []
436
+ }
437
+
413
438
  function nodeMiddlewareWarns(projectDir) {
414
439
  const warns = []
415
440
  let pkg = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kywi-app",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Scaffold a new Kywi CMS project — npx create-kywi-app my-site",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/Kywi-Software/kywi-cms#readme",