@simmalugnt-se/payload-content-health 0.2.1 → 0.3.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 +7 -0
- package/README.md +9 -6
- package/dist/checks.d.ts +1 -0
- package/dist/checks.js +14 -3
- package/dist/copy.js +12 -4
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- "Fix with the assistant" on a missing meta title or description says how long to write it
|
|
6
|
+
("Write a meta title for this page, 50–60 characters."), from the same range as the length check.
|
|
7
|
+
Without it the assistant wrote titles well under the range. Findings for a missing meta title or
|
|
8
|
+
description carry that range as `range`.
|
|
9
|
+
|
|
3
10
|
## 0.2.1
|
|
4
11
|
|
|
5
12
|
- The work list at `/admin/content-health` requires Admin access. Payload leaves custom Admin views
|
package/README.md
CHANGED
|
@@ -115,9 +115,10 @@ or block the unsaved form no longer has opens the nearest enclosing field instea
|
|
|
115
115
|
|
|
116
116
|
With `@simmalugnt-se/payload-editor-assistant` (0.5.0 or later), rows in the collections the
|
|
117
117
|
assistant works in also get "Fix with the assistant": the same link with a ready prompt that the
|
|
118
|
-
assistant puts in its message box
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
assistant puts in its message box, with the length to aim for when a meta title or description is
|
|
119
|
+
missing or off. The editor sends it. To write a missing alt text, the assistant needs to see the
|
|
120
|
+
image: allow `media.view` on the media collection (0.6.0 or later). The packages do not import each
|
|
121
|
+
other; they share these names:
|
|
121
122
|
|
|
122
123
|
| Name | Direction | Meaning |
|
|
123
124
|
| -------------------------------------------- | ----------------------- | ---------------------------------------- |
|
|
@@ -137,6 +138,8 @@ import { scanContentHealth } from "@simmalugnt-se/payload-content-health";
|
|
|
137
138
|
const { findings, problems } = await scanContentHealth({ payload, user: req.user });
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
Each finding is
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
Each finding is
|
|
142
|
+
`{ check, collection, id, title, path, locale?, length?, range?, heading?, words?, status? }`, where
|
|
143
|
+
`path` is the form path with row indexes (`layout.1.items.0.title`) and `range` is the length a
|
|
144
|
+
missing meta title or description should have. `problems` lists configured checks that could not
|
|
145
|
+
run, such as a field path that does not exist.
|
package/dist/checks.d.ts
CHANGED
package/dist/checks.js
CHANGED
|
@@ -25,13 +25,23 @@ export function rulesFor(options) {
|
|
|
25
25
|
const titleLength = seo.titleLength ?? SEO_DEFAULTS.titleLength;
|
|
26
26
|
const descriptionLength = seo.descriptionLength ?? SEO_DEFAULTS.descriptionLength;
|
|
27
27
|
if (title) {
|
|
28
|
-
rules.push({
|
|
28
|
+
rules.push({
|
|
29
|
+
check: "seo.title-missing",
|
|
30
|
+
kind: "required",
|
|
31
|
+
path: title,
|
|
32
|
+
...(titleLength ? { range: titleLength } : {}),
|
|
33
|
+
});
|
|
29
34
|
if (titleLength) {
|
|
30
35
|
rules.push({ check: "seo.title-length", kind: "length", path: title, range: titleLength });
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
if (description) {
|
|
34
|
-
rules.push({
|
|
39
|
+
rules.push({
|
|
40
|
+
check: "seo.description-missing",
|
|
41
|
+
kind: "required",
|
|
42
|
+
path: description,
|
|
43
|
+
...(descriptionLength ? { range: descriptionLength } : {}),
|
|
44
|
+
});
|
|
35
45
|
if (descriptionLength) {
|
|
36
46
|
rules.push({
|
|
37
47
|
check: "seo.description-length",
|
|
@@ -105,7 +115,8 @@ export function checkDocument(input) {
|
|
|
105
115
|
}
|
|
106
116
|
checked.push(rule.check);
|
|
107
117
|
if (isEmpty(value)) {
|
|
108
|
-
|
|
118
|
+
// The assistant writes to the length the length check will expect.
|
|
119
|
+
findings.push(rule.range ? { ...base, range: rule.range } : base);
|
|
109
120
|
}
|
|
110
121
|
continue;
|
|
111
122
|
}
|
package/dist/copy.js
CHANGED
|
@@ -122,11 +122,15 @@ export const COPY = {
|
|
|
122
122
|
export const ASK = {
|
|
123
123
|
en: {
|
|
124
124
|
"media.alt-missing": () => "Write an alt text for this image.",
|
|
125
|
-
"seo.title-missing": () =>
|
|
125
|
+
"seo.title-missing": ({ range }) => range
|
|
126
|
+
? `Write a meta title for this page, ${range.min}–${range.max} characters.`
|
|
127
|
+
: "Write a meta title for this page.",
|
|
126
128
|
"seo.title-length": ({ length }) => length
|
|
127
129
|
? `The meta title is ${length.actual} characters. Rewrite it to ${length.min}–${length.max} characters.`
|
|
128
130
|
: "Rewrite the meta title to a better length.",
|
|
129
|
-
"seo.description-missing": () =>
|
|
131
|
+
"seo.description-missing": ({ range }) => range
|
|
132
|
+
? `Write a meta description for this page, ${range.min}–${range.max} characters.`
|
|
133
|
+
: "Write a meta description for this page.",
|
|
130
134
|
"seo.description-length": ({ length }) => length
|
|
131
135
|
? `The meta description is ${length.actual} characters. Rewrite it to ${length.min}–${length.max} characters.`
|
|
132
136
|
: "Rewrite the meta description to a better length.",
|
|
@@ -142,11 +146,15 @@ export const ASK = {
|
|
|
142
146
|
},
|
|
143
147
|
sv: {
|
|
144
148
|
"media.alt-missing": () => "Skriv en alt-text för den här bilden.",
|
|
145
|
-
"seo.title-missing": () =>
|
|
149
|
+
"seo.title-missing": ({ range }) => range
|
|
150
|
+
? `Skriv en metatitel för den här sidan, ${range.min}–${range.max} tecken.`
|
|
151
|
+
: "Skriv en metatitel för den här sidan.",
|
|
146
152
|
"seo.title-length": ({ length }) => length
|
|
147
153
|
? `Metatiteln är ${length.actual} tecken. Skriv om den till ${length.min}–${length.max} tecken.`
|
|
148
154
|
: "Skriv om metatiteln till en bättre längd.",
|
|
149
|
-
"seo.description-missing": () =>
|
|
155
|
+
"seo.description-missing": ({ range }) => range
|
|
156
|
+
? `Skriv en metabeskrivning för den här sidan, ${range.min}–${range.max} tecken.`
|
|
157
|
+
: "Skriv en metabeskrivning för den här sidan.",
|
|
150
158
|
"seo.description-length": ({ length }) => length
|
|
151
159
|
? `Metabeskrivningen är ${length.actual} tecken. Skriv om den till ${length.min}–${length.max} tecken.`
|
|
152
160
|
: "Skriv om metabeskrivningen till en bättre längd.",
|
package/dist/types.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export type Finding = {
|
|
|
19
19
|
length?: LengthRange & {
|
|
20
20
|
actual: number;
|
|
21
21
|
};
|
|
22
|
+
/** For a missing meta title or description: the length its length check expects. */
|
|
23
|
+
range?: LengthRange;
|
|
22
24
|
/** For heading checks: the heading's level and, for a skip, the level before it. */
|
|
23
25
|
heading?: {
|
|
24
26
|
level: number;
|
package/package.json
CHANGED