canopycms 0.3.3 → 0.5.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/CHANGELOG.md +91 -41
- package/dist/ai/generate.d.ts +3 -0
- package/dist/ai/generate.js +23 -33
- package/dist/ai/handler.js +1 -0
- package/dist/ai/types.d.ts +6 -11
- package/dist/api/reference-options.d.ts +2 -5
- package/dist/api/reference-options.js +21 -2
- package/dist/api/schema.d.ts +4 -4
- package/dist/build/generate-ai-content.js +1 -0
- package/dist/cli/cli.js +176 -66
- package/dist/cli/generate-ai-content.js +122 -62
- package/dist/cli/init.js +29 -4
- package/dist/config/index.d.ts +1 -1
- package/dist/config/schemas/config.d.ts +74 -0
- package/dist/config/schemas/config.js +21 -0
- package/dist/config/schemas/field.d.ts +30 -0
- package/dist/config/schemas/field.js +22 -0
- package/dist/config/types.d.ts +47 -8
- package/dist/config/validation.d.ts +6 -0
- package/dist/config/validation.js +33 -0
- package/dist/content-store.d.ts +5 -4
- package/dist/content-store.js +12 -7
- package/dist/editor/FormRenderer.js +15 -13
- package/dist/editor/copy.d.ts +5 -0
- package/dist/editor/copy.js +5 -0
- package/dist/editor/fields/BlockField.d.ts +2 -0
- package/dist/editor/fields/BlockField.js +15 -8
- package/dist/editor/fields/ItemList.d.ts +21 -3
- package/dist/editor/fields/ItemList.js +16 -8
- package/dist/editor/fields/NumberListField.d.ts +2 -0
- package/dist/editor/fields/NumberListField.js +6 -2
- package/dist/editor/fields/ObjectListField.js +9 -3
- package/dist/editor/fields/ReferenceField.d.ts +6 -7
- package/dist/editor/fields/ReferenceField.js +28 -122
- package/dist/editor/fields/ReferenceListField.d.ts +41 -0
- package/dist/editor/fields/ReferenceListField.js +139 -0
- package/dist/editor/fields/SelectField.d.ts +2 -0
- package/dist/editor/fields/SelectField.js +6 -3
- package/dist/editor/fields/StringListField.d.ts +10 -1
- package/dist/editor/fields/StringListField.js +18 -8
- package/dist/editor/fields/item-expansion.d.ts +7 -3
- package/dist/editor/fields/item-expansion.js +6 -4
- package/dist/editor/fields/list-item-keys.d.ts +6 -5
- package/dist/editor/fields/list-item-keys.js +45 -13
- package/dist/editor/fields/reference-noindex.d.ts +37 -0
- package/dist/editor/fields/reference-noindex.js +48 -0
- package/dist/editor/fields/use-reference-options.d.ts +36 -0
- package/dist/editor/fields/use-reference-options.js +121 -0
- package/dist/editor/form-outline.d.ts +2 -2
- package/dist/editor/form-outline.js +4 -2
- package/dist/editor/theme.js +5 -0
- package/dist/entry-schema-registry.d.ts +1 -1
- package/dist/entry-schema-registry.js +3 -2
- package/dist/entry-schema.d.ts +21 -9
- package/dist/entry-schema.js +5 -2
- package/dist/reference-resolver.d.ts +18 -1
- package/dist/reference-resolver.js +175 -8
- package/dist/schema/schema-store.d.ts +2 -2
- package/dist/static/index.d.ts +8 -4
- package/dist/static/index.js +38 -13
- package/dist/static/seo.d.ts +7 -5
- package/dist/static/seo.js +13 -6
- package/dist/utils/body-field.d.ts +9 -1
- package/dist/utils/body-field.js +18 -1
- package/dist/validation/entry-validator.d.ts +5 -0
- package/dist/validation/entry-validator.js +12 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,9 @@ packages release together, at one version.
|
|
|
5
5
|
|
|
6
6
|
## This build
|
|
7
7
|
|
|
8
|
-
Version `0.
|
|
8
|
+
Version `0.5.0`, built from [`3576327`](https://github.com/safeinsights/canopycms/tree/3576327ebf2ba4ab163b234d3f1e36318ff1c37f).
|
|
9
9
|
|
|
10
|
-
Its entries are [0.
|
|
10
|
+
Its entries are [0.5.0](#050), under **Released**.
|
|
11
11
|
|
|
12
12
|
If you upgraded from a build on another branch, compare the `<!-- changeset: … -->` slugs in your previous build's `CHANGELOG.md` (`npm pack canopycms@<old>` fetches it) with this one's: entries whose slug your old file lacks are new to you.
|
|
13
13
|
|
|
@@ -24,7 +24,7 @@ Each entry has up to three parts:
|
|
|
24
24
|
`node_modules/canopycms/CHANGELOG.md`, assembled for that build: its **This build** section lists
|
|
25
25
|
what is new since the previous int on the same branch, or on a stable release links its entries, and its links point at the commit the build
|
|
26
26
|
came from. The copy in the repository holds released history and the entries from before changesets;
|
|
27
|
-
every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/
|
|
27
|
+
every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/.changeset/README.md) until a stable release
|
|
28
28
|
moves it here.
|
|
29
29
|
|
|
30
30
|
**Find your starting point.** From a stable pin, start at the first version under **Released**
|
|
@@ -62,6 +62,56 @@ entries under **Released**.
|
|
|
62
62
|
|
|
63
63
|
## Released
|
|
64
64
|
|
|
65
|
+
### 0.5.0
|
|
66
|
+
|
|
67
|
+
#### Reorderable list references, and `maxItems` on list fields — **behaviour change: a build fails on a list over its cap**
|
|
68
|
+
|
|
69
|
+
<!-- changeset: reference-list-reorder-and-max-items -->
|
|
70
|
+
|
|
71
|
+
_First in 0.5.0._
|
|
72
|
+
|
|
73
|
+
**What changed.** A `type: 'reference', list: true` field now edits as rows in stored order, like an `object` list: drag a row or use its "…" menu to move or remove it, open a row to swap its entry in place, and pick from Add under the rows to append. Neither control offers an entry the list already holds. Any `list: true` field, and any `block` field, takes `maxItems`. The editor stops adding at the cap and says why, a save over it is refused, and a production build fails on an entry over it, naming the entry, field, count and cap. Adding `maxItems` to a list that already holds more therefore fails the build until an editor removes the extra items. `maxItems` on a field that holds no items is refused when the entry schema registry is created.
|
|
74
|
+
|
|
75
|
+
**To adopt.** Set `maxItems: 3` on the list field in its entry schema. See [Field Types](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#field-types).
|
|
76
|
+
|
|
77
|
+
#### SEO field location moves into config; reference pickers mark hidden entries and take a sort order — **breaking: `createNextCanopyContext({ seo })` and `AIContentConfig.seo` are removed**
|
|
78
|
+
|
|
79
|
+
<!-- changeset: seo-config-hidden-picks-option-sort -->
|
|
80
|
+
|
|
81
|
+
_First in 0.5.0._
|
|
82
|
+
|
|
83
|
+
**What changed.** `defineCanopyConfig` takes `seo: { group?, fields? }`, the one place every surface reads an entry's `noindex` flag: the sitemap and `entryToMetadata` that `createNextCanopyContext` returns, AI content and the editor's reference picker. A per-call `seo`/`group`/`fields` still overrides it. The free `generateContentSitemap` takes `seo` as an argument and refuses to run without it when the config sets one; `createNextCanopyContext` and the AI content config refuse a leftover `seo`. A reference picker now badges an entry hidden from search as "Hidden from search", and picking one adds a note naming the setting on that entry's form, since a page listing only indexed entries won't show it. A reference field takes `optionSort`: `'label'` (the default), `'collection'`, or `{ field, direction }`. Point `field` at an ISO date, since strings compare as text.
|
|
84
|
+
|
|
85
|
+
**To adopt.** Move `seo` from `createNextCanopyContext({ seo })` and from `defineAIContentConfig({ seo })` into `defineCanopyConfig({ seo })`. See [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#sitemap-and-seo-metadata) and [How References Work in the Editor](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#how-references-work-in-the-editor).
|
|
86
|
+
|
|
87
|
+
**Now deletable.** A shared `seo` constant passed separately to the Next context and the AI content config.
|
|
88
|
+
|
|
89
|
+
### 0.4.0
|
|
90
|
+
|
|
91
|
+
#### Link-only references to json/yaml entries leave out the body — **behaviour change (resolved data and types)**
|
|
92
|
+
|
|
93
|
+
<!-- changeset: link-only-references-omit-data-body -->
|
|
94
|
+
|
|
95
|
+
_First in 0.4.0._
|
|
96
|
+
|
|
97
|
+
**What changed.** A reference field without `includeBody: true` now resolves a json or yaml
|
|
98
|
+
target without that target's `isBody` field, as it already resolved an md/mdx target without its
|
|
99
|
+
body. A long body is no longer copied into every entry that merely links to it. A field that is
|
|
100
|
+
only named `body`, with no `isBody`, is ordinary data and still resolves. The live-preview resolve
|
|
101
|
+
endpoint and the AI export's `referenceLink` target follow the same rule, and `referenceLink`
|
|
102
|
+
now receives a json/yaml target's `isBody` field as `context.body`. Live preview resolves every
|
|
103
|
+
reference link-only, so an `includeBody: true` reference to a json/yaml target now previews
|
|
104
|
+
without its body, as one to an md/mdx target already did.
|
|
105
|
+
|
|
106
|
+
With `resolvedSchema`, the target's `isBody` field is now optional in the resolved type unless
|
|
107
|
+
the reference sets `includeBody: true`. This applies to md/mdx targets too, which already
|
|
108
|
+
resolved without it.
|
|
109
|
+
|
|
110
|
+
**To adopt.** Where a reference renders its target's prose, set `includeBody: true` on that
|
|
111
|
+
reference field. Code that reads the body from a link-only reference's resolved type now sees
|
|
112
|
+
`string | undefined`; either set `includeBody: true` or handle the missing value. See
|
|
113
|
+
[Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#resolving-references-in-a-listing).
|
|
114
|
+
|
|
65
115
|
### 0.3.3
|
|
66
116
|
|
|
67
117
|
#### Bare URLs in a markdown body survive a save
|
|
@@ -471,7 +521,7 @@ URL.
|
|
|
471
521
|
2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
|
|
472
522
|
`app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
|
|
473
523
|
route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
|
|
474
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
524
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#live-preview)).
|
|
475
525
|
3. A test reading view content from the route's server HTML must load the page in a browser.
|
|
476
526
|
Server output rendered during a preview request carries the signed-in asset prefix; keep it out
|
|
477
527
|
of cross-request caches (`unstable_cache`, module memos).
|
|
@@ -486,7 +536,7 @@ kept site styles ahead of Mantine's in the preview.
|
|
|
486
536
|
server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
|
|
487
537
|
path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
|
|
488
538
|
refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
|
|
489
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
539
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#live-preview).
|
|
490
540
|
|
|
491
541
|
**To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
|
|
492
542
|
as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
|
|
@@ -568,7 +618,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
|
|
|
568
618
|
fields are nested or renamed, pass the AI config's `seo` the same object you pass
|
|
569
619
|
`createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
|
|
570
620
|
place. A field that links to a hidden section by plain URL needs a field transform; the README
|
|
571
|
-
shows [the recipe](https://github.com/safeinsights/canopycms/blob/
|
|
621
|
+
shows [the recipe](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#ai-content-configuration).
|
|
572
622
|
|
|
573
623
|
**Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
|
|
574
624
|
|
|
@@ -590,7 +640,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
|
|
|
590
640
|
field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
|
|
591
641
|
`MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
|
|
592
642
|
`{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
|
|
593
|
-
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/
|
|
643
|
+
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#mdx-content-cannot-run-code).
|
|
594
644
|
|
|
595
645
|
**To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
|
|
596
646
|
`mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
|
|
@@ -727,7 +777,7 @@ a format check.
|
|
|
727
777
|
|
|
728
778
|
- (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
|
|
729
779
|
re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
|
|
730
|
-
([reference](https://github.com/safeinsights/canopycms/blob/
|
|
780
|
+
([reference](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#definecanopyconfig-options)).
|
|
731
781
|
- (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
|
|
732
782
|
the PR-body section every user who edited the branch, not only the submitter; settings commits
|
|
733
783
|
(permissions, groups) carry the acting user's trailer.
|
|
@@ -751,7 +801,7 @@ saves only push the branch, and no failing PR task lands in System health.
|
|
|
751
801
|
that entry type goes unavailable: the editor says so, and its entries answer 503 with
|
|
752
802
|
`code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
|
|
753
803
|
worker holds the base branch for up to 30 minutes while that lasts; see
|
|
754
|
-
[New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/
|
|
804
|
+
[New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
|
|
755
805
|
Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
|
|
756
806
|
`ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
|
|
757
807
|
|
|
@@ -789,7 +839,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
|
|
|
789
839
|
new stack needs no steps.
|
|
790
840
|
|
|
791
841
|
**What changed.** (int.109) Detailed in
|
|
792
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
842
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
|
|
793
843
|
bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
|
|
794
844
|
refusing clients without TLS or IAM, replacing the worker's
|
|
795
845
|
`AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
|
|
@@ -843,10 +893,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
|
|
|
843
893
|
with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
|
|
844
894
|
unchanged.
|
|
845
895
|
- `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
|
|
846
|
-
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/
|
|
896
|
+
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#worker-down-alarm).
|
|
847
897
|
|
|
848
898
|
**To adopt.** Optional. For parameter-only change sets, see
|
|
849
|
-
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/
|
|
899
|
+
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
|
|
850
900
|
`alarmTopic`.
|
|
851
901
|
|
|
852
902
|
**Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
|
|
@@ -857,7 +907,7 @@ worker, and a hand-built alarm on the worker log group.
|
|
|
857
907
|
**What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
|
|
858
908
|
swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
|
|
859
909
|
`alarmTopic` if set; a retried step names itself when it gives up. See
|
|
860
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
910
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance).
|
|
861
911
|
|
|
862
912
|
**To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
|
|
863
913
|
not Template first and the worker contract stays at 1.
|
|
@@ -923,7 +973,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
|
|
|
923
973
|
|
|
924
974
|
**To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
|
|
925
975
|
mirror, so the root volume needs room for two
|
|
926
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
976
|
+
([details](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance)).
|
|
927
977
|
|
|
928
978
|
#### The worker follows a rebased or deleted GitHub branch
|
|
929
979
|
|
|
@@ -945,7 +995,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
|
|
|
945
995
|
bundle-only roll is safe.
|
|
946
996
|
|
|
947
997
|
**To adopt.** Parameter mode: gate bundle-only rolls on the contract
|
|
948
|
-
([recipe](https://github.com/safeinsights/canopycms/blob/
|
|
998
|
+
([recipe](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
|
|
949
999
|
`WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
|
|
950
1000
|
copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
|
|
951
1001
|
|
|
@@ -962,8 +1012,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
|
|
|
962
1012
|
template, then roll the bundle; on an older template it stops with `template too old for this
|
|
963
1013
|
bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
|
|
964
1014
|
takes `worker/`'s three units and `gateway.env.example`
|
|
965
|
-
([steps](https://github.com/safeinsights/canopycms/blob/
|
|
966
|
-
[checklist](https://github.com/safeinsights/canopycms/blob/
|
|
1015
|
+
([steps](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
|
|
1016
|
+
[checklist](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#first-deploy-checklist).
|
|
967
1017
|
|
|
968
1018
|
#### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
|
|
969
1019
|
|
|
@@ -974,7 +1024,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
|
|
|
974
1024
|
`X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
|
|
975
1025
|
its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
|
|
976
1026
|
marked `noindex`. The editor's default preview is same-origin and unaffected. See
|
|
977
|
-
[Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/
|
|
1027
|
+
[Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
|
|
978
1028
|
|
|
979
1029
|
**To adopt.** If you wired the Function URL into your own distribution by hand, delete those
|
|
980
1030
|
behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
|
|
@@ -1150,7 +1200,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
|
|
|
1150
1200
|
**To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
|
|
1151
1201
|
apply the same rule here, for example `referenceLink: (target, { body }) =>
|
|
1152
1202
|
!body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
|
|
1153
|
-
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1203
|
+
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#ai-content-configuration).
|
|
1154
1204
|
|
|
1155
1205
|
**Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
|
|
1156
1206
|
change its link.
|
|
@@ -1225,7 +1275,7 @@ _First in int.115._
|
|
|
1225
1275
|
entry the base branch also changed, the "updated on the base branch" notice and the branch's
|
|
1226
1276
|
conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
|
|
1227
1277
|
base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
|
|
1228
|
-
and Unpublishing](https://github.com/safeinsights/canopycms/blob/
|
|
1278
|
+
and Unpublishing](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#drafts-and-unpublishing) section covers long-lived branches and
|
|
1229
1279
|
unpublishing.
|
|
1230
1280
|
|
|
1231
1281
|
#### The editor calls the content drawer "All content"
|
|
@@ -1537,7 +1587,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
|
|
|
1537
1587
|
The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
|
|
1538
1588
|
|
|
1539
1589
|
**To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
|
|
1540
|
-
`{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/
|
|
1590
|
+
`{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#stamping-a-publication-date).
|
|
1541
1591
|
|
|
1542
1592
|
**Now deletable.** A build step or hook that writes a missing publication date into new entries.
|
|
1543
1593
|
|
|
@@ -1584,7 +1634,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
|
|
|
1584
1634
|
stored at, and `react-split-pane` is no longer a dependency.
|
|
1585
1635
|
`EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
|
|
1586
1636
|
no longer exported from `canopycms/client`. See
|
|
1587
|
-
[Your root layout](https://github.com/safeinsights/canopycms/blob/
|
|
1637
|
+
[Your root layout](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#editor-customization).
|
|
1588
1638
|
|
|
1589
1639
|
**To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
|
|
1590
1640
|
instead, which lays out its own panes. Hiding your site chrome on the editor route is now
|
|
@@ -1695,7 +1745,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
|
|
|
1695
1745
|
**To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
|
|
1696
1746
|
`ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
|
|
1697
1747
|
own pages, mount the hook as in
|
|
1698
|
-
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/
|
|
1748
|
+
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
|
|
1699
1749
|
Your own Server Actions in the CMS build still 403 behind OAC.
|
|
1700
1750
|
|
|
1701
1751
|
**Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
|
|
@@ -1736,12 +1786,12 @@ fast naming the ARN, the field and the keys present, never a value.
|
|
|
1736
1786
|
**To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
|
|
1737
1787
|
prop. The scaffolded stack fills them from the repository _variables_
|
|
1738
1788
|
`CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
|
|
1739
|
-
([why the prefix](https://github.com/safeinsights/canopycms/blob/
|
|
1789
|
+
([why the prefix](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
|
|
1740
1790
|
adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
|
|
1741
1791
|
lines to `.github/workflows/deploy-cms.yml`, or re-runs the generator and diffs. `cdk synth` refuses a `…JsonField` prop without its `…SecretArn`, and an ARN carrying the ECS `:KEY::` suffix
|
|
1742
1792
|
(also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
|
|
1743
1793
|
resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
|
|
1744
|
-
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
1794
|
+
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#security-model)).
|
|
1745
1795
|
|
|
1746
1796
|
**Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
|
|
1747
1797
|
worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
|
|
@@ -1753,7 +1803,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
|
|
|
1753
1803
|
`githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
|
|
1754
1804
|
nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
|
|
1755
1805
|
anyone holding an App's key can mint a token for any of its installations
|
|
1756
|
-
([why](https://github.com/safeinsights/canopycms/blob/
|
|
1806
|
+
([why](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
|
|
1757
1807
|
|
|
1758
1808
|
**To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
|
|
1759
1809
|
`githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
|
|
@@ -1766,7 +1816,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1766
1816
|
`verify` checks an existing installation's permissions: run it, since an App missing a
|
|
1767
1817
|
permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
|
|
1768
1818
|
never edits an existing JSON secret (create one and point the JSON-field prop at it)
|
|
1769
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
1819
|
+
([details](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
|
|
1770
1820
|
2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
|
|
1771
1821
|
of the three is refused at synth, and so is an App alongside a token.
|
|
1772
1822
|
3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
|
|
@@ -1777,7 +1827,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1777
1827
|
|
|
1778
1828
|
The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
|
|
1779
1829
|
IAM policy automatically, so you need not add it to `secretsArns`. See
|
|
1780
|
-
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/
|
|
1830
|
+
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#authenticating-as-a-github-app).
|
|
1781
1831
|
|
|
1782
1832
|
```bash
|
|
1783
1833
|
canopycms init-github-app create -- \
|
|
@@ -1825,7 +1875,7 @@ downloads the `.pem` from the App's settings page.
|
|
|
1825
1875
|
|
|
1826
1876
|
**What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
|
|
1827
1877
|
key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
|
|
1828
|
-
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/
|
|
1878
|
+
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rotating-a-secret).
|
|
1829
1879
|
|
|
1830
1880
|
**To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
|
|
1831
1881
|
GitHub App private key is still read only at boot: store the new key, replace the instance, and
|
|
@@ -1879,12 +1929,12 @@ also check the bucket policy for its grant.
|
|
|
1879
1929
|
5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
|
|
1880
1930
|
Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
|
|
1881
1931
|
`webpack` and it can read your Next version. A webpack build still fails its image transforms
|
|
1882
|
-
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/
|
|
1932
|
+
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#dual-build-support)).
|
|
1883
1933
|
|
|
1884
1934
|
**Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
|
|
1885
1935
|
function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
|
|
1886
1936
|
function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
|
|
1887
|
-
on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/
|
|
1937
|
+
on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#where-the-image-is-built)).
|
|
1888
1938
|
|
|
1889
1939
|
**To adopt.**
|
|
1890
1940
|
|
|
@@ -1913,7 +1963,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
|
|
|
1913
1963
|
|
|
1914
1964
|
**What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
|
|
1915
1965
|
replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
|
|
1916
|
-
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1966
|
+
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#media-configuration) for the
|
|
1917
1967
|
CloudFront behavior it expects.
|
|
1918
1968
|
|
|
1919
1969
|
**To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
|
|
@@ -1938,7 +1988,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
|
|
|
1938
1988
|
bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
|
|
1939
1989
|
`Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
|
|
1940
1990
|
`AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
|
|
1941
|
-
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/
|
|
1991
|
+
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#cross-account-asset-bucket).
|
|
1942
1992
|
|
|
1943
1993
|
**To adopt.** Optional:
|
|
1944
1994
|
|
|
@@ -2048,7 +2098,7 @@ public JWKS PEM, used only to verify signatures.
|
|
|
2048
2098
|
to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
|
|
2049
2099
|
deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
|
|
2050
2100
|
`clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
|
|
2051
|
-
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
2101
|
+
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#security-model)).
|
|
2052
2102
|
|
|
2053
2103
|
#### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
|
|
2054
2104
|
|
|
@@ -2147,7 +2197,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
|
|
2147
2197
|
Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
|
|
2148
2198
|
no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
|
|
2149
2199
|
`AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
|
|
2150
|
-
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
2200
|
+
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#media-configuration)). Two traps:
|
|
2151
2201
|
|
|
2152
2202
|
- Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
|
|
2153
2203
|
a nested route prefix and emits zero params, building green.
|
|
@@ -2306,7 +2356,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
|
|
|
2306
2356
|
`withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
|
|
2307
2357
|
`canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
|
|
2308
2358
|
`createNextCanopyContext`'s result. See
|
|
2309
|
-
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/
|
|
2359
|
+
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#sitemap-and-seo-metadata). Every routable entry type is in
|
|
2310
2360
|
the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
|
|
2311
2361
|
sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
|
|
2312
2362
|
filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
|
|
@@ -2363,7 +2413,7 @@ underscore-prefixed files are skipped.
|
|
|
2363
2413
|
|
|
2364
2414
|
**What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
|
|
2365
2415
|
`defaultPathAccess: { read: 'allow' }`
|
|
2366
|
-
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/
|
|
2416
|
+
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#public-read-on-server-deployments)).
|
|
2367
2417
|
|
|
2368
2418
|
**To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
|
|
2369
2419
|
consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
|
|
@@ -2416,7 +2466,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
|
|
|
2416
2466
|
**What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
|
|
2417
2467
|
gives one template's value type) requires exactly
|
|
2418
2468
|
one component per block template name when written as an object literal. See
|
|
2419
|
-
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/
|
|
2469
|
+
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#block-component-registries) and
|
|
2420
2470
|
`apps/example1/app/components/PostView.tsx`.
|
|
2421
2471
|
|
|
2422
2472
|
```ts
|
|
@@ -2438,7 +2488,7 @@ templates against the schema.
|
|
|
2438
2488
|
|
|
2439
2489
|
**What changed.** Spreading a `const` field array into several schemas, and nesting
|
|
2440
2490
|
`defineInlineFieldGroup()` inside a block template, are documented
|
|
2441
|
-
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/
|
|
2491
|
+
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
|
|
2442
2492
|
identity helper for them.
|
|
2443
2493
|
|
|
2444
2494
|
```ts
|
|
@@ -2457,7 +2507,7 @@ field by composing from the same `const` field object.
|
|
|
2457
2507
|
A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
|
|
2458
2508
|
it, and listings do with
|
|
2459
2509
|
[`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
|
|
2460
|
-
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/
|
|
2510
|
+
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#shared--referenced-blocks).
|
|
2461
2511
|
|
|
2462
2512
|
**Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
|
|
2463
2513
|
|
|
@@ -2479,7 +2529,7 @@ Not retro-documented, apart from these:
|
|
|
2479
2529
|
|
|
2480
2530
|
#### The registry is keyed by entry-type name (0.0.42)
|
|
2481
2531
|
|
|
2482
|
-
**What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/
|
|
2532
|
+
**What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
|
|
2483
2533
|
|
|
2484
2534
|
**To adopt.**
|
|
2485
2535
|
|
package/dist/ai/generate.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import type { ContentStore } from '../content-store.js';
|
|
9
9
|
import type { FlatSchemaItem } from '../config/index.js';
|
|
10
10
|
import { type EntryLinkUrlResolver } from '../entry-link-resolver.js';
|
|
11
|
+
import { type SeoFieldLocation } from '../static/seo.js';
|
|
11
12
|
import type { AIContentConfig, AIManifest } from './types.js';
|
|
12
13
|
export interface GenerateOptions {
|
|
13
14
|
store: ContentStore;
|
|
@@ -17,6 +18,8 @@ export interface GenerateOptions {
|
|
|
17
18
|
config?: AIContentConfig;
|
|
18
19
|
/** Custom URL resolver for entry links. */
|
|
19
20
|
entryLinkUrl?: EntryLinkUrlResolver;
|
|
21
|
+
/** Where entries keep their SEO fields: `CanopyConfig.seo`. Drives the `noindex` read. */
|
|
22
|
+
seo?: SeoFieldLocation;
|
|
20
23
|
/**
|
|
21
24
|
* ISO-8601 timestamp to record as the manifest's `generated`. Defaults to now.
|
|
22
25
|
*
|
package/dist/ai/generate.js
CHANGED
|
@@ -9,6 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import fs from 'node:fs/promises';
|
|
10
10
|
import { minimatch } from 'minimatch';
|
|
11
11
|
import { isDataOnlyFormat } from '../utils/format.js';
|
|
12
|
+
import { findExplicitBodyFieldName, linkOnlyReferenceData } from '../utils/body-field.js';
|
|
12
13
|
import { extractEntryTypeFromFilename, extractIdFromFilename, } from '../content-id-index.js';
|
|
13
14
|
import { hasTraversalSequence } from '../paths/index.js';
|
|
14
15
|
import { getErrorMessage, isNodeError } from '../utils/error.js';
|
|
@@ -17,7 +18,7 @@ import { entryToMarkdown, frontmatterTitle } from './json-to-markdown.js';
|
|
|
17
18
|
import { createReferenceRendering, createReferenceTargetResolver, decideReferenceLinks, maskUnexportedTargets, resolveReferenceFields, } from './references.js';
|
|
18
19
|
import { resolveEntryLinksInText } from '../entry-link-resolver.js';
|
|
19
20
|
import { computeEntryUrl } from '../utils/entry-url.js';
|
|
20
|
-
import {
|
|
21
|
+
import { isNoindexEntry } from '../static/seo.js';
|
|
21
22
|
/**
|
|
22
23
|
* Generate all AI content from the content store.
|
|
23
24
|
*
|
|
@@ -31,7 +32,7 @@ import { DEFAULT_SEO_FIELD_NAMES, isNoindexEntry } from '../static/seo.js';
|
|
|
31
32
|
* rendered, in rounds that repeat while a render fails (see the loop below).
|
|
32
33
|
*/
|
|
33
34
|
export async function generateAIContent(options) {
|
|
34
|
-
const { store, flatSchema, contentRoot, config, entryLinkUrl, generatedAt, buildId } = options;
|
|
35
|
+
const { store, flatSchema, contentRoot, config, entryLinkUrl, seo, generatedAt, buildId } = options;
|
|
35
36
|
assertValidNoindexConfig(config);
|
|
36
37
|
assertValidReferenceLink(config);
|
|
37
38
|
const files = new Map();
|
|
@@ -42,6 +43,7 @@ export async function generateAIContent(options) {
|
|
|
42
43
|
config,
|
|
43
44
|
idIndex,
|
|
44
45
|
entryLinkUrl,
|
|
46
|
+
seo,
|
|
45
47
|
resolveTarget: createReferenceTargetResolver(store),
|
|
46
48
|
};
|
|
47
49
|
const collections = flatSchema.filter((item) => item.type === 'collection');
|
|
@@ -76,19 +78,24 @@ export async function generateAIContent(options) {
|
|
|
76
78
|
pendingById.set(pending.contentId, pending);
|
|
77
79
|
}
|
|
78
80
|
// The target as `resolveReferenceTarget` would give it, built from this export's own read, so
|
|
79
|
-
// an entry outside the export set is never offered and a target cannot change mid-run
|
|
81
|
+
// an entry outside the export set is never offered and a target cannot change mid-run. A
|
|
82
|
+
// json/yaml target's `isBody` field is its body here, as an md/mdx target's body is
|
|
80
83
|
const subjectOf = (id) => {
|
|
81
84
|
const pending = pendingById.get(id);
|
|
82
85
|
if (!pending || !exported.has(id))
|
|
83
86
|
return undefined;
|
|
84
|
-
const {
|
|
85
|
-
const
|
|
87
|
+
const { format } = pending;
|
|
88
|
+
const { slug, fields } = pending.entry;
|
|
89
|
+
const storedData = structuredClone(pending.storedData);
|
|
90
|
+
const target = buildResolvedReference(linkOnlyReferenceData(storedData, format, fields), {
|
|
86
91
|
id,
|
|
87
92
|
slug,
|
|
88
93
|
collection: pending.collectionPath,
|
|
89
94
|
urlPath: computeEntryUrl(pending.collectionPath, slug, contentRoot),
|
|
90
95
|
});
|
|
91
|
-
|
|
96
|
+
const dataBodyField = isDataOnlyFormat(format) ? findExplicitBodyFieldName(fields) : undefined;
|
|
97
|
+
const dataBody = dataBodyField === undefined ? undefined : storedData[dataBodyField];
|
|
98
|
+
return { target, body: pending.body ?? (typeof dataBody === 'string' ? dataBody : undefined) };
|
|
92
99
|
};
|
|
93
100
|
const linkFor = config?.referenceLink
|
|
94
101
|
? await decideReferenceLinks(config.referenceLink, allPending, subjectOf, entryLinkUrl)
|
|
@@ -219,7 +226,7 @@ async function collectCollection(read, collection, flatSchema) {
|
|
|
219
226
|
}
|
|
220
227
|
/** Read, resolve and filter the entries directly in `collection` (not its subcollections). */
|
|
221
228
|
async function collectEntries(read, collection, cleanPath) {
|
|
222
|
-
const { store, contentRoot, config, idIndex, entryLinkUrl, resolveTarget } = read;
|
|
229
|
+
const { store, contentRoot, config, idIndex, entryLinkUrl, seo, resolveTarget } = read;
|
|
223
230
|
const skipNoindex = config?.exclude?.noindex !== false;
|
|
224
231
|
const pending = [];
|
|
225
232
|
const listed = await store.getCollectionEntryPaths(collection.logicalPath);
|
|
@@ -239,7 +246,7 @@ async function collectEntries(read, collection, cleanPath) {
|
|
|
239
246
|
resolveReferences: false,
|
|
240
247
|
});
|
|
241
248
|
// AI content advertises an entry, so `noindex` leaves it out here as it does the sitemap.
|
|
242
|
-
if (skipNoindex && isNoindexEntry(doc.data,
|
|
249
|
+
if (skipNoindex && isNoindexEntry(doc.data, seo))
|
|
243
250
|
continue;
|
|
244
251
|
const storedData = doc.data;
|
|
245
252
|
doc.data = await resolveReferenceFields(doc.data, entryTypeConfig.schema, resolveTarget);
|
|
@@ -254,6 +261,7 @@ async function collectEntries(read, collection, cleanPath) {
|
|
|
254
261
|
entry: aiEntry,
|
|
255
262
|
body,
|
|
256
263
|
storedData,
|
|
264
|
+
format: doc.format,
|
|
257
265
|
linkedIds: [],
|
|
258
266
|
contentId: extractIdFromFilename(path.basename(listEntry.relativePath)),
|
|
259
267
|
absolutePath: doc.absolutePath,
|
|
@@ -310,37 +318,19 @@ function assertValidReferenceLink(config) {
|
|
|
310
318
|
}
|
|
311
319
|
}
|
|
312
320
|
/**
|
|
313
|
-
* Refuse
|
|
314
|
-
*
|
|
315
|
-
*
|
|
321
|
+
* Refuse a non-boolean `exclude.noindex`: `noindex: 'false'` would leave the gate on while the
|
|
322
|
+
* adopter believes it is off. Refuse `seo` too: the location is `CanopyConfig.seo`, and an AI
|
|
323
|
+
* config loaded without type checking would otherwise drop it silently and ship every noindex
|
|
324
|
+
* entry. `CanopyConfig.seo`'s shape is checked by the config schema.
|
|
316
325
|
*/
|
|
317
326
|
function assertValidNoindexConfig(config) {
|
|
318
327
|
const noindex = config?.exclude?.noindex;
|
|
319
328
|
if (noindex !== undefined && typeof noindex !== 'boolean') {
|
|
320
329
|
throw new Error(`AI content config: exclude.noindex must be a boolean, got ${typeof noindex}`);
|
|
321
330
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (typeof seo !== 'object' || seo === null || Array.isArray(seo)) {
|
|
326
|
-
throw new Error('AI content config: seo must be an object of { group?, fields? }');
|
|
327
|
-
}
|
|
328
|
-
const { group, fields } = seo;
|
|
329
|
-
if (group !== undefined && typeof group !== 'string') {
|
|
330
|
-
throw new Error('AI content config: seo.group must be a string');
|
|
331
|
-
}
|
|
332
|
-
if (fields === undefined)
|
|
333
|
-
return;
|
|
334
|
-
if (typeof fields !== 'object' ||
|
|
335
|
-
fields === null ||
|
|
336
|
-
Array.isArray(fields) ||
|
|
337
|
-
Object.values(fields).some((name) => typeof name !== 'string')) {
|
|
338
|
-
throw new Error('AI content config: seo.fields must map SEO fields to field-name strings');
|
|
339
|
-
}
|
|
340
|
-
// An unknown key (`noIndex`) would leave the gate reading the default field name
|
|
341
|
-
const unknown = Object.keys(fields).filter((key) => !(key in DEFAULT_SEO_FIELD_NAMES));
|
|
342
|
-
if (unknown.length > 0) {
|
|
343
|
-
throw new Error(`AI content config: unknown seo.fields key(s): ${unknown.join(', ')}`);
|
|
331
|
+
if (config && 'seo' in config) {
|
|
332
|
+
throw new Error('AI content config: seo is not an AI content option. Set it once as seo in defineCanopyConfig, ' +
|
|
333
|
+
'where the sitemap, page metadata and AI content all read it.');
|
|
344
334
|
}
|
|
345
335
|
}
|
|
346
336
|
function stripContentRoot(logicalPath, contentRoot) {
|
package/dist/ai/handler.js
CHANGED
package/dist/ai/types.d.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { FieldConfig } from '../config/index.js';
|
|
8
8
|
import type { MissingReference, ResolvedReferenceMeta } from '../entry-schema.js';
|
|
9
|
-
import type { SeoFieldLocation } from '../static/seo.js';
|
|
10
9
|
/** A reference whose target this export shows: the target's own data plus where it lives. */
|
|
11
10
|
export type AIResolvedReference = Record<string, unknown> & ResolvedReferenceMeta & {
|
|
12
11
|
unavailable?: undefined;
|
|
@@ -62,9 +61,9 @@ export interface ExcludeConfig {
|
|
|
62
61
|
/** Custom predicate — return true to exclude the entry */
|
|
63
62
|
where?: (entry: AIEntryMeta) => boolean;
|
|
64
63
|
/**
|
|
65
|
-
* Leave out entries marked `noindex`, read through `isNoindexEntry` at
|
|
66
|
-
*
|
|
67
|
-
*
|
|
64
|
+
* Leave out entries marked `noindex`, read through `isNoindexEntry` at `config.seo`, the
|
|
65
|
+
* predicate and location the sitemap and robots metadata use. Default `true`; `false` exports
|
|
66
|
+
* them.
|
|
68
67
|
*/
|
|
69
68
|
noindex?: boolean;
|
|
70
69
|
}
|
|
@@ -208,8 +207,9 @@ export type EntryTransforms = Record<string, EntryTransformFn>;
|
|
|
208
207
|
/** What {@link AIReferenceLinkFn} knows about a target beyond its data. */
|
|
209
208
|
export interface AIReferenceLinkContext {
|
|
210
209
|
/**
|
|
211
|
-
* The target's
|
|
212
|
-
*
|
|
210
|
+
* The target's body as stored: an md/mdx entry's body, or a json/yaml entry's `isBody` field,
|
|
211
|
+
* which the target leaves out as a link-only reference does. `undefined` when it has none. It
|
|
212
|
+
* only informs this decision: none of it reaches the entries that link to the target.
|
|
213
213
|
*/
|
|
214
214
|
body: string | undefined;
|
|
215
215
|
/**
|
|
@@ -246,11 +246,6 @@ export interface AIContentConfig {
|
|
|
246
246
|
mountPath?: string;
|
|
247
247
|
/** Opt-out exclusions — content to skip */
|
|
248
248
|
exclude?: ExcludeConfig;
|
|
249
|
-
/**
|
|
250
|
-
* Where entries keep their SEO fields, when not the flat defaults. Drives the `noindex` read,
|
|
251
|
-
* so pass the same object as `createNextCanopyContext({ seo })`, or the two can disagree.
|
|
252
|
-
*/
|
|
253
|
-
seo?: SeoFieldLocation;
|
|
254
249
|
/** Custom bundles — filtered content subsets */
|
|
255
250
|
bundles?: BundleConfig[];
|
|
256
251
|
/** Per-entry-type, per-field markdown overrides */
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ApiResponse } from './types.js';
|
|
3
|
+
import { type ReferenceOption } from '../reference-resolver.js';
|
|
3
4
|
export type ReferenceOptionsResponse = ApiResponse<{
|
|
4
|
-
options:
|
|
5
|
-
id: string;
|
|
6
|
-
label: string;
|
|
7
|
-
collection: string;
|
|
8
|
-
}>;
|
|
5
|
+
options: ReferenceOption[];
|
|
9
6
|
}>;
|
|
10
7
|
/**
|
|
11
8
|
* Exported routes for router registration
|