create-kywi-app 0.25.0 → 0.27.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.
@@ -35,8 +35,8 @@ The build rule that follows: **prefer structures that show up in those
35
35
  surfaces.** A headline in a `heading` module is editable in all three; the same
36
36
  headline in a hand-written component is editable in none. Custom modules (§5)
37
37
  must expose their copy as first-class props for the same reason — and a module
38
- whose *first* declared prop is `text`, `textarea` or `richText` becomes
39
- inline-editable on the front of the site for free.
38
+ that marks each copy element with `useInlinePropAnchor()` becomes
39
+ inline-editable on the front of the site, one field per double-click.
40
40
 
41
41
  ## Before you build: design the content model and get sign-off
42
42
 
@@ -532,10 +532,19 @@ 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
- **Declare the primary copy prop first.** The front-of-site editor makes a
536
- module's *first* prop inline-editable on the page when its type is `text`,
537
- `textarea` or `richText` — so `props: { headline, … }` can be typed over
538
- directly on the live page, and `props: { variant, headline, … }` cannot.
535
+ **Anchor every copy prop in the component.** The front-of-site editor edits
536
+ one prop at a time, in the element that renders it. Mark that element with
537
+ `useInlinePropAnchor()` from `@kywi-software/core/layout` —
538
+ `<h2 {...anchor('headline')}>{headline}</h2>` — and double-clicking it edits
539
+ `headline` in place. The anchor only renders inside the editor, so published
540
+ markup is unchanged; never hardcode `data-kywi-prop`. Anchor only an element
541
+ whose text is *exactly* the prop's value (no prefix, suffix or sibling value).
542
+
543
+ Without anchors, only a module with exactly **one** `text` / `textarea` /
544
+ `richText` prop, declared first, is inline-editable (the whole module binds to
545
+ it). A module with two or more text props and no anchors — a heading plus a
546
+ body — is **not** editable in place: double-click opens the props rail, and the
547
+ editor logs a dev-mode warning naming the module.
539
548
 
540
549
  Also: create **saved layouts** (Layouts admin) as page templates — "Landing
541
550
  page", "Case study" — so new pages start from a consistent skeleton. A saved
@@ -843,6 +852,24 @@ early, so ask at scoping time.
843
852
  `robots.txt` at the site root out of the box — a Kywi site is legible to
844
853
  agents and crawlers by default. Don't remove these routes; they're part of
845
854
  the product's value.
855
+ - **Pre-launch sites are hidden from search.** A site answering on a platform
856
+ preview address (`*.up.railway.app`, `*.vercel.app`, …) is blocked
857
+ automatically: `robots.txt` says `Disallow: /`, the sitemap and llms files
858
+ 404, and every response carries `X-Robots-Tag: noindex, nofollow`. Set
859
+ `KYWI_INDEXING=off` on any other pre-launch or staging host. **At launch**,
860
+ when the site answers on its real domain, remove `KYWI_INDEXING=off` (or set
861
+ `on`) — the admin shows a "Search engines are blocked" banner until you do.
862
+ Never hide a site from search by editing robots policy by hand; use this
863
+ switch.
864
+ - **Every page has a Markdown copy when `ax.markdown` is on.** `/<path>.md`
865
+ serves it, and the home page is `/index.md`. The page head advertises it with
866
+ `<link rel="alternate" type="text/markdown">`, but only when the copy really
867
+ answers. Set `KYWI_AX_MARKDOWN=on` so agents that send
868
+ `Accept: text/markdown` to the page URL get the copy too, and
869
+ `KYWI_AX_LLMS=on` to advertise `/llms.txt` in a `Link` header. The edge
870
+ cannot read `kywi.config.ts`, so these env vars mirror config; keep them in
871
+ step. Never write a static `public/llms.txt` or a hand-made `.md` file — the
872
+ generated ones follow every publish.
846
873
 
847
874
  ## Other capabilities worth knowing
848
875
 
@@ -62,10 +62,12 @@ Two rules that decide whether the module is really editable:
62
62
  - **Keep owner copy out of `json`.** `stats: {type:'json'}` hands the owner a
63
63
  JSON blob; `stat1Value` / `stat1Label` / `stat2Value` … as `text` props hands
64
64
  them fields. Use `json` only for structure that never changes after build.
65
- - **Declare the primary copy prop first.** The front-of-site editor makes a
66
- module's *first* prop inline-editable on the live page when its type is
67
- `text`, `textarea` or `richText`. Put the headline first; put `variant` and
68
- layout switches after it.
65
+ - **Anchor every copy prop in the component (step 4).** The front-of-site
66
+ editor edits one prop at a time, in the element marked with
67
+ `useInlinePropAnchor()`. A module with two or more `text` / `textarea` /
68
+ `richText` props and no anchors is **not** inline-editable — double-click
69
+ falls back to the props rail. (Unanchored, only a module with a single text
70
+ prop, declared first, edits in place.)
69
71
 
70
72
  ### 3. Register it — `defineModule` in `kywi.config.ts`
71
73
 
@@ -81,7 +83,7 @@ export default defineKywiConfig({
81
83
  component: 'splitFeature', // the key you'll map in lib/modules.tsx
82
84
  category: 'Marketing', // groups it in the palette
83
85
  props: {
84
- heading: { type: 'text', label: 'Heading' }, // first = inline-editable
86
+ heading: { type: 'text', label: 'Heading' }, // anchored in step 4
85
87
  body: { type: 'richText', label: 'Body' },
86
88
  image: { type: 'image', label: 'Image' },
87
89
  imageAlt: { type: 'text', label: 'Image alt text' },
@@ -106,15 +108,16 @@ export default defineKywiConfig({
106
108
  ```tsx
107
109
  // lib/split-feature.tsx
108
110
  'use client'
109
- import { resolveMediaRef } from '@kywi-software/core/layout'
111
+ import { resolveMediaRef, useInlinePropAnchor } from '@kywi-software/core/layout'
110
112
 
111
113
  export function SplitFeature({ props }: { props: Record<string, unknown> }) {
112
114
  const src = resolveMediaRef(props.image) // media UUID → public file URL
115
+ const anchor = useInlinePropAnchor() // editor-only; adds nothing on the live site
113
116
  return (
114
117
  <div className={`split-feature${props.reverse === true ? ' is-reversed' : ''}`}>
115
118
  <div className="split-feature__copy">
116
- <h2>{String(props.heading ?? '')}</h2>
117
- <div dangerouslySetInnerHTML={{ __html: String(props.body ?? '') }} />
119
+ <h2 {...anchor('heading')}>{String(props.heading ?? '')}</h2>
120
+ <div {...anchor('body')} dangerouslySetInnerHTML={{ __html: String(props.body ?? '') }} />
118
121
  </div>
119
122
  {src ? <img src={src} alt={String(props.imageAlt ?? '')} /> : null}
120
123
  </div>
@@ -125,6 +128,12 @@ export function SplitFeature({ props }: { props: Record<string, unknown> }) {
125
128
  Every prop is `unknown` — coerce and default each one. A module that throws on a
126
129
  missing prop breaks the editor canvas as well as the page.
127
130
 
131
+ `anchor('heading')` marks the element that renders exactly that prop, so
132
+ double-clicking it on the page edits `heading` in place. Anchor each copy prop's
133
+ own element, and only one whose text is *exactly* the prop's value — not
134
+ `<span>{price}/{period}</span>`, which stays rail-only. Don't hardcode
135
+ `data-kywi-prop`: the hook emits it only inside the editor.
136
+
128
137
  ### 5. Map it in `lib/modules.tsx`
129
138
 
130
139
  ```tsx
package/lib/templates.mjs CHANGED
@@ -296,8 +296,9 @@ export default defineKywiConfig({
296
296
  // component: 'splitFeature', // the key you map in lib/modules.tsx
297
297
  // category: 'Marketing',
298
298
  // props: {
299
- // // First text prop = inline-editable on the live page. Keep owner
300
- // // copy in text/textarea/richText props, never in a json blob.
299
+ // // Keep owner copy in text/textarea/richText props, never in a json
300
+ // // blob, and mark each one's element with useInlinePropAnchor() so
301
+ // // it is inline-editable on the live page.
301
302
  // heading: { type: 'text', label: 'Heading' },
302
303
  // body: { type: 'richText', label: 'Body' },
303
304
  // image: { type: 'image', label: 'Image' },
@@ -460,6 +461,22 @@ AUTH_SECRET=CHANGE_ME
460
461
  # kywi.config.ts on disk.
461
462
  # KYWI_API_URL=http://localhost:3000/api/v1
462
463
  # KYWI_API_KEY=
464
+
465
+ # Search indexing. Unset = indexable, EXCEPT on platform preview addresses
466
+ # (*.up.railway.app, *.vercel.app, *.netlify.app, …), which are blocked
467
+ # automatically. off = robots.txt Disallow-all, no sitemap/llms files, and a
468
+ # noindex header on every response — use it on a pre-launch or staging host.
469
+ # Set on at launch (or remove it once the site answers on its real domain).
470
+ # KYWI_INDEXING=off
471
+
472
+ # Agent discovery at the edge. The middleware cannot read kywi.config.ts, so
473
+ # these mirror the AX config there — keep each in step with its setting.
474
+ # KYWI_AX_LLMS=on adds a \`Link: </llms.txt>; rel="describedby"\` header to public
475
+ # pages (mirror of ax.llmsTxt.enabled, which is on by default).
476
+ # KYWI_AX_MARKDOWN=on answers \`Accept: text/markdown\` on page URLs with the
477
+ # page's Markdown copy (mirror of ax.markdown.enabled, which is off by default).
478
+ KYWI_AX_LLMS=on
479
+ # KYWI_AX_MARKDOWN=on
463
480
  `
464
481
  }
465
482
 
@@ -1264,6 +1281,7 @@ const route = createAxRoute({ runtime: kywi, axPath: '${axPath}' })
1264
1281
 
1265
1282
  /** Root-level \`/${axPath}\` — delegates to the core AX generator (kywi-cms#55). */
1266
1283
  export const GET = route.GET
1284
+ export const HEAD = route.HEAD
1267
1285
 
1268
1286
  export const dynamic = 'force-dynamic'
1269
1287
  `)
@@ -1311,6 +1329,7 @@ export const POST = route.POST
1311
1329
  export const PUT = route.PUT
1312
1330
  export const PATCH = route.PATCH
1313
1331
  export const DELETE = route.DELETE
1332
+ export const HEAD = route.HEAD
1314
1333
 
1315
1334
  export const dynamic = 'force-dynamic'
1316
1335
  `)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kywi-app",
3
- "version": "0.25.0",
3
+ "version": "0.27.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",