@simmalugnt-se/payload-content-health 0.10.1 → 0.10.3
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 +11 -0
- package/dist/assistant.d.ts +2 -0
- package/dist/assistant.js +7 -5
- package/dist/styles/view.css +0 -13
- package/dist/view/WorkList.js +2 -2
- package/dist/widget/ContentHealthWidget.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.3
|
|
4
|
+
|
|
5
|
+
- The work list's labels (documents, language, draft) are Payload's own pills, so they follow
|
|
6
|
+
Admin's theme.
|
|
7
|
+
|
|
8
|
+
## 0.10.2
|
|
9
|
+
|
|
10
|
+
- The assistant's findings name checks and categories as the work list does, in the editor's chat
|
|
11
|
+
language (with editor-assistant 0.17.0 or later): it said "orphan page" in Swedish, translating the
|
|
12
|
+
check's id, where the work list says "Inget länkar hit".
|
|
13
|
+
|
|
3
14
|
## 0.10.1
|
|
4
15
|
|
|
5
16
|
- Shorter instructions to the editor assistant: two rules the evals show it no longer needs are
|
package/dist/assistant.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type AssistantExtensionContext = {
|
|
|
32
32
|
id?: string | number;
|
|
33
33
|
locale: string;
|
|
34
34
|
};
|
|
35
|
+
/** The editor's chat language (editor-assistant 0.17.0 or later); labels are given in it. */
|
|
36
|
+
language?: "sv" | "en";
|
|
35
37
|
};
|
|
36
38
|
export type AssistantExtensionResult = {
|
|
37
39
|
ok: true;
|
package/dist/assistant.js
CHANGED
|
@@ -47,7 +47,7 @@ export function assistantExtension({ scan: run = scanContentHealth, } = {}) {
|
|
|
47
47
|
id: EXTENSION_ID,
|
|
48
48
|
instructions: [
|
|
49
49
|
"Content health checks the site's content: SEO (meta titles, descriptions, share images, duplicates), structure (H1, heading levels, thin content, broken internal links, also in the header and footer, and pages nothing links to), translations (fields empty in a language) and accessibility (image alt texts).",
|
|
50
|
-
"When the editor asks what needs work, how the site or a page is doing, or what to fix first, call content-health.findings and answer from it, naming pages and problems.",
|
|
50
|
+
"When the editor asks what needs work, how the site or a page is doing, or what to fix first, call content-health.findings and answer from it, naming pages and problems. Each finding's problem is the work list's name for it, in the editor's language when known: use it as it is.",
|
|
51
51
|
'Each finding says how it is fixed: "batch" (many documents at once from the work list), "assistant" (on the document, with you) or "by hand". To start fixing, call content-health.open: with batch true for a batch check, else the work list. It takes the editor there; they start the fix and review each change themselves. Say where they are now ("The 9 missing alt texts are open; Fix 9 with the assistant starts them."). Do not propose changes yourself for findings outside the open document. Do not mention findings the tool left out unless the editor asks for more.',
|
|
52
52
|
].join(" "),
|
|
53
53
|
views: [
|
|
@@ -97,7 +97,9 @@ export function assistantExtension({ scan: run = scanContentHealth, } = {}) {
|
|
|
97
97
|
],
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
async function findings(input, { req, open }, result) {
|
|
100
|
+
async function findings(input, { req, open, language }, result) {
|
|
101
|
+
// The work list's own names, in the editor's language, so the model need not translate them.
|
|
102
|
+
const names = language === "sv" ? "sv" : "en";
|
|
101
103
|
const custom = req.payload.config.admin?.custom;
|
|
102
104
|
const withAssistant = new Set(assistantCollections(custom));
|
|
103
105
|
const inBatches = new Set(batchCollections(custom));
|
|
@@ -126,7 +128,7 @@ async function findings(input, { req, open }, result) {
|
|
|
126
128
|
documentsNeedingAttention: countDocuments(result.findings),
|
|
127
129
|
categories: categoryStats(stats).map((stat) => ({
|
|
128
130
|
category: stat.category,
|
|
129
|
-
label: CATEGORY_LABELS
|
|
131
|
+
label: CATEGORY_LABELS[names][stat.category],
|
|
130
132
|
issues: stat.failing,
|
|
131
133
|
fieldsChecked: stat.checked,
|
|
132
134
|
})),
|
|
@@ -134,8 +136,8 @@ async function findings(input, { req, open }, result) {
|
|
|
134
136
|
scope: document ? "one document" : filtered ? "filtered" : "whole site",
|
|
135
137
|
findings: matching.slice(0, limit).map((finding) => ({
|
|
136
138
|
check: finding.check,
|
|
137
|
-
problem: CHECK_LABELS
|
|
138
|
-
detail: findingDetail(
|
|
139
|
+
problem: CHECK_LABELS[names][finding.check],
|
|
140
|
+
detail: findingDetail(names, finding),
|
|
139
141
|
collection: finding.collection,
|
|
140
142
|
id: finding.id,
|
|
141
143
|
...(finding.global ? { global: true } : {}),
|
package/dist/styles/view.css
CHANGED
|
@@ -240,19 +240,6 @@
|
|
|
240
240
|
font-size: 0.9em;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
.content-health-list__pill {
|
|
244
|
-
padding: 0 calc(var(--base) * 0.3);
|
|
245
|
-
border-radius: var(--style-radius-s);
|
|
246
|
-
background: var(--theme-elevation-100);
|
|
247
|
-
color: var(--theme-elevation-800);
|
|
248
|
-
font-size: 0.8em;
|
|
249
|
-
text-transform: uppercase;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
.content-health-list__pill--draft {
|
|
253
|
-
text-transform: none;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
243
|
.content-health-list__empty {
|
|
257
244
|
margin: 0;
|
|
258
245
|
padding: var(--base) 0;
|
package/dist/view/WorkList.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button, Link, ReactSelect } from "@payloadcms/ui";
|
|
3
|
+
import { Button, Link, Pill, ReactSelect } from "@payloadcms/ui";
|
|
4
4
|
import { useId, useMemo, useState } from "react";
|
|
5
5
|
import { categoryOf } from "../categories.js";
|
|
6
6
|
import { LIST_COPY } from "../copy.js";
|
|
@@ -59,7 +59,7 @@ function Section({ adminRoute, ask, copy, filters, rows, }) {
|
|
|
59
59
|
const batchHref = ask && targets.length > 1
|
|
60
60
|
? batchURL(adminRoute, { ...filters, check }, targets, ask)
|
|
61
61
|
: undefined;
|
|
62
|
-
return (_jsxs("section", { className: "content-health-list__section", children: [_jsxs("header", { className: "content-health-list__section-head", children: [_jsx("h2", { children: rows[0]?.checkLabel }), _jsx(
|
|
62
|
+
return (_jsxs("section", { className: "content-health-list__section", children: [_jsxs("header", { className: "content-health-list__section-head", children: [_jsx("h2", { children: rows[0]?.checkLabel }), _jsx(Pill, { pillStyle: "light-gray", size: "small", children: copy.documents(documents) }), batchHref ? (_jsx(Button, { buttonStyle: "secondary", className: "content-health-list__batch", el: "link", margin: false, size: "small", url: batchHref, children: copy.fixMany(Math.min(targets.length, MAX_BATCH_TARGETS), targets.length) })) : null] }), !BATCH_CHECKS[check] && rows.some((row) => row.askHref) ? (_jsx("p", { className: "content-health-list__detail", children: copy.individualFix })) : null, _jsx("ul", { className: "content-health-list__items", children: rows.map((row) => (_jsxs("li", { className: "content-health-list__item", children: [_jsx(Link, { href: row.href, prefetch: false, children: row.title }), row.locale ? (_jsx(Pill, { pillStyle: "light-gray", size: "small", children: row.locale.toUpperCase() })) : null, row.draft ? (_jsx(Pill, { pillStyle: "warning", size: "small", children: copy.draft })) : null, row.detail ? _jsx("span", { className: "content-health-list__detail", children: row.detail }) : null, row.askHref ? (_jsx(Link, { className: "content-health-list__fix", href: row.askHref, prefetch: false, children: copy.fix })) : null] }, row.key))) })] }));
|
|
63
63
|
}
|
|
64
64
|
function Filter({ all, label, onChange, options, value, }) {
|
|
65
65
|
const inputId = useId();
|
|
@@ -30,6 +30,7 @@ export async function ContentHealthWidget({ req, widgetData }) {
|
|
|
30
30
|
const failing = stats.reduce((sum, stat) => sum + stat.failing, 0);
|
|
31
31
|
const documents = Object.values(result.documents).reduce((sum, count) => sum + count, 0);
|
|
32
32
|
const adminRoute = req.payload.config.routes.admin;
|
|
33
|
+
// A panel of our own: Payload's `Card` is a link to one collection, not a summary with categories.
|
|
33
34
|
return (_jsxs("section", { className: "content-health", children: [_jsx("h2", { className: "content-health__heading", children: copy.title }), _jsxs("div", { className: "content-health__panel", children: [_jsxs("div", { className: "content-health__overview", children: [_jsx(Ring, { className: "content-health__ring", failing: failing, label: copy.ok(total - failing, total), total: total }), _jsxs("div", { className: "content-health__overview-text", children: [_jsx("p", { className: "content-health__overall", children: copy.overall }), _jsx("p", { className: "content-health__summary", children: result.findings.length
|
|
34
35
|
? copy.summary(countDocuments(result.findings), documents)
|
|
35
36
|
: copy.allGood })] }), _jsx(Button, { buttonStyle: "secondary", el: "link", margin: false, size: "small", url: listURL(adminRoute), children: copy.openDetails })] }), _jsx("ul", { className: "content-health__categories", children: categories.map((stat) => (_jsx(CategoryRow, { adminRoute: adminRoute, language: language, stat: stat }, stat.category))) }), result.problems.length ? (_jsxs("div", { className: "content-health__problems", children: [_jsx("p", { children: copy.problems }), _jsx("ul", { children: result.problems.map((problem) => (_jsx("li", { children: problem }, problem))) })] })) : null] })] }));
|
package/package.json
CHANGED