seo-supervisor 0.0.0-stage → 2.0.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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +16 -0
- package/.claude-plugin/plugin.json +27 -0
- package/CHANGELOG.md +461 -0
- package/LICENSE +25 -0
- package/NOTICE +7 -0
- package/README.md +402 -2
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +230 -0
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +96 -0
- package/bin/seo-supervisor.mjs +477 -0
- package/commands/seo-audit.md +33 -0
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +34 -0
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +21 -0
- package/commands/seo-review.md +19 -0
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +35 -0
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +58 -4
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +480 -0
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +532 -0
- package/skills/seo-supervisor/examples/sample-report.html +704 -0
- package/skills/seo-supervisor/examples/sample-report.md +360 -0
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/security-tools-profile.md +73 -0
- package/skills/seo-supervisor/examples/snippets.md +781 -0
- package/skills/seo-supervisor/frameworks/nextjs.md +98 -0
- package/skills/seo-supervisor/frameworks/rails.md +34 -0
- package/skills/seo-supervisor/frameworks/spa.md +14 -0
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +157 -0
- package/skills/seo-supervisor/profile-template.md +96 -0
- package/skills/seo-supervisor/report-format.md +313 -0
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +93 -0
- package/skills/seo-supervisor/rules/content.md +84 -0
- package/skills/seo-supervisor/rules/crawl-index.md +92 -0
- package/skills/seo-supervisor/rules/internal-linking.md +104 -0
- package/skills/seo-supervisor/rules/launch-monitoring.md +57 -0
- package/skills/seo-supervisor/rules/media.md +42 -0
- package/skills/seo-supervisor/rules/metadata.md +71 -0
- package/skills/seo-supervisor/rules/performance.md +78 -0
- package/skills/seo-supervisor/rules/rendering.md +79 -0
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +49 -0
- package/skills/seo-supervisor/rules/structured-data.md +98 -0
- package/skills/seo-supervisor/rules/trust-security.md +48 -0
- package/skills/seo-supervisor/rules/urls.md +54 -0
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +530 -0
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/fonts/OFL-BricolageGrotesque.txt +93 -0
- package/skills/seo-supervisor/scripts/fonts/OFL-Geist.txt +93 -0
- package/skills/seo-supervisor/scripts/fonts/OFL-GeistMono.txt +93 -0
- package/skills/seo-supervisor/scripts/fonts/bricolage-grotesque.woff2 +0 -0
- package/skills/seo-supervisor/scripts/fonts/geist-mono.woff2 +0 -0
- package/skills/seo-supervisor/scripts/fonts/geist.woff2 +0 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +340 -0
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +241 -0
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1151 -0
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +55 -0
- package/skills/seo-supervisor/site-types/ecommerce.md +64 -0
- package/skills/seo-supervisor/site-types/local-business.md +118 -0
- package/skills/seo-supervisor/site-types/services.md +68 -0
- package/skills/seo-supervisor/site-types/tools.md +127 -0
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The report's /seo-setup plan section as stats, HTML and Markdown. The plan's shape is in report-format.md.
|
|
3
|
+
import { safeHref, cellMd, mdSafe, noteMd } from "./report/format.mjs";
|
|
4
|
+
|
|
5
|
+
const STATUSES = ["exists", "to-build", "built", "to-create"];
|
|
6
|
+
const LABEL = { exists: "Already right", "to-build": "To build", built: "Built", "to-create": "To create" };
|
|
7
|
+
const PLAN_LABEL = {
|
|
8
|
+
proposed: "Proposed: waiting for your approval",
|
|
9
|
+
approved: "Approved: being built",
|
|
10
|
+
built: "Built",
|
|
11
|
+
};
|
|
12
|
+
const NEEDS = { copy: "Copy", facts: "Facts", decision: "A decision", yes: "Your yes" };
|
|
13
|
+
|
|
14
|
+
const key = r => r.url || r.pattern || "";
|
|
15
|
+
const isDone = r => r.status === "exists" || r.status === "built";
|
|
16
|
+
const ownerOpen = r => r.owner && r.owner.done !== true && r.owner.declined !== true;
|
|
17
|
+
const yesOpen = y => y.approved !== true && y.declined !== true;
|
|
18
|
+
// Only an http(s) URL or a plain relative path (drafts/privacy.md) is linked. Anything else (javascript:, data:,
|
|
19
|
+
// //host, \\server) shows as text, so a click can't run a script in the report. Paths with spaces or non-ASCII letters
|
|
20
|
+
// are text too; widen the pattern if real drafts need them.
|
|
21
|
+
const draftHref = d => (typeof d === "string" ? safeHref(d) || (/^[\w.~-][\w.~%+/-]*$/.test(d) ? d : null) : null);
|
|
22
|
+
|
|
23
|
+
export function planStats(plan) {
|
|
24
|
+
const pages = Array.isArray(plan?.pages) ? plan.pages : [];
|
|
25
|
+
const byStatus = Object.fromEntries(STATUSES.map(s => [s, 0]));
|
|
26
|
+
let done = 0;
|
|
27
|
+
for (const r of pages) {
|
|
28
|
+
if (r.status in byStatus) byStatus[r.status]++;
|
|
29
|
+
if (isDone(r)) done += 1;
|
|
30
|
+
else if (r.pattern && r.count > 0) done += Math.min(1, Math.max(0, (Number(r.built) || 0) / r.count));
|
|
31
|
+
}
|
|
32
|
+
const yesItems = (plan?.yes || []).filter(yesOpen).length;
|
|
33
|
+
return {
|
|
34
|
+
rows: pages.length,
|
|
35
|
+
byStatus,
|
|
36
|
+
progress: pages.length ? Math.round((100 * done) / pages.length) : 0,
|
|
37
|
+
ownerOpen: pages.filter(ownerOpen).length,
|
|
38
|
+
yesOpen: yesItems + pages.filter(r => ownerOpen(r) && r.owner.needs === "yes").length,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {any} plan
|
|
44
|
+
* @param {{ esc: (s: any) => string, inl: (s: any) => string, num: (n: any) => string, traffic?: (url: string) => string | null }} helpers
|
|
45
|
+
*/
|
|
46
|
+
export function planHtml(plan, { esc, inl, num, traffic = () => null }) {
|
|
47
|
+
const pages = Array.isArray(plan?.pages) ? plan.pages : [];
|
|
48
|
+
const s = planStats(plan);
|
|
49
|
+
const chip = st => `<span class="pchip s-${esc(st)}">${esc(LABEL[st] || st)}</span>`;
|
|
50
|
+
const head = `<section class="panel plan-sum" aria-labelledby="h-plan">
|
|
51
|
+
<div class="ph"><h2 id="h-plan">SEO plan</h2><span class="sub">${esc(PLAN_LABEL[plan.status] || plan.status || "")}${plan.approvedOn ? ` · approved ${esc(plan.approvedOn)}` : ""}</span></div>
|
|
52
|
+
<div class="plan-prog">
|
|
53
|
+
<p class="plan-n"><span class="n">${s.progress}%</span>of the agent's work is done</p>
|
|
54
|
+
<div class="pbar" role="img" aria-label="Plan progress: ${s.progress}% of the agent's work is done"><i style="width:${s.progress}%"></i></div>
|
|
55
|
+
</div>
|
|
56
|
+
<ul class="plan-counts">${STATUSES.filter(st => s.byStatus[st])
|
|
57
|
+
.map(st => `<li>${chip(st)}<b>${num(s.byStatus[st])}</b></li>`)
|
|
58
|
+
.join("")}${s.ownerOpen ? `<li><span class="own">Needs you</span><b>${num(s.ownerOpen)}</b></li>` : ""}</ul>
|
|
59
|
+
${plan.summary ? `<p class="plan-summary">${inl(plan.summary)}</p>` : ""}
|
|
60
|
+
${fixesLine(
|
|
61
|
+
plan,
|
|
62
|
+
n => num(n),
|
|
63
|
+
ids => ids.map(id => `<a href="#${esc(id)}">${esc(id)}</a>`).join(", "),
|
|
64
|
+
)}
|
|
65
|
+
</section>`;
|
|
66
|
+
if (!pages.length)
|
|
67
|
+
return `<div class="plan">${head}<section class="panel empty-state"><h2>No pages in this plan yet</h2><p>Run /seo-setup to propose one.</p></section></div>`;
|
|
68
|
+
|
|
69
|
+
const yes = [
|
|
70
|
+
...(plan.yes || [])
|
|
71
|
+
.filter(yesOpen)
|
|
72
|
+
.map(
|
|
73
|
+
y =>
|
|
74
|
+
`<li><b>${esc(y.id || "")}</b> ${inl(y.what)}${y.why ? `<span class="quiet"> · ${inl(y.why)}</span>` : ""}</li>`,
|
|
75
|
+
),
|
|
76
|
+
...pages
|
|
77
|
+
.filter(r => ownerOpen(r) && r.owner.needs === "yes")
|
|
78
|
+
.map(r => `<li><code>${esc(key(r))}</code> ${inl(r.owner.what || "")}</li>`),
|
|
79
|
+
];
|
|
80
|
+
const declined = [
|
|
81
|
+
...(plan.yes || []).filter(y => y.declined === true).map(y => `<b>${esc(y.id || "")}</b> ${inl(y.what)}`),
|
|
82
|
+
...pages
|
|
83
|
+
.filter(r => r.owner && r.owner.declined === true)
|
|
84
|
+
.map(r => `<code>${esc(key(r))}</code> ${inl(r.owner.what || "")}`),
|
|
85
|
+
];
|
|
86
|
+
const yesHtml =
|
|
87
|
+
yes.length || declined.length
|
|
88
|
+
? `<section class="panel plan-yes" aria-labelledby="h-yes"><h2 id="h-yes">Needs your yes</h2>
|
|
89
|
+
${yes.length ? `<p class="quiet">Each of these changes needs its own yes before the agent makes it. Approving the plan doesn't cover them.</p><ol>${yes.join("")}</ol>` : `<p class="quiet">Nothing is waiting for your yes.</p>`}
|
|
90
|
+
${declined.length ? `<p class="plan-declined"><span class="quiet">Declined by you, so the agent won't make these changes:</span> ${declined.join("; ")}</p>` : ""}</section>`
|
|
91
|
+
: "";
|
|
92
|
+
|
|
93
|
+
// Site structure from `parent`; rows whose parent isn't in the plan are roots.
|
|
94
|
+
const keys = new Set(pages.map(key));
|
|
95
|
+
const kids = new Map();
|
|
96
|
+
for (const r of pages) {
|
|
97
|
+
const p = keys.has(r.parent) && r.parent !== key(r) ? r.parent : "";
|
|
98
|
+
(kids.get(p) || kids.set(p, []).get(p)).push(r);
|
|
99
|
+
}
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
const tree = parent => {
|
|
102
|
+
const list = (kids.get(parent) || []).filter(r => !seen.has(key(r)));
|
|
103
|
+
if (!list.length) return "";
|
|
104
|
+
return `<ul>${list
|
|
105
|
+
.map(r => {
|
|
106
|
+
seen.add(key(r));
|
|
107
|
+
return `<li><code>${esc(key(r))}</code>${r.pattern ? ` <span class="pcount">×${num(r.count || 0)}</span>` : ""} ${chip(r.status)}${tree(key(r))}</li>`;
|
|
108
|
+
})
|
|
109
|
+
.join("")}</ul>`;
|
|
110
|
+
};
|
|
111
|
+
const treeHtml = `<section class="panel plan-tree" aria-labelledby="h-tree"><h2 id="h-tree">Site structure</h2>${tree("")}</section>`;
|
|
112
|
+
|
|
113
|
+
const field = (label, v) =>
|
|
114
|
+
v == null || v === "" || (Array.isArray(v) && !v.length)
|
|
115
|
+
? ""
|
|
116
|
+
: `<dt>${label}</dt><dd>${Array.isArray(v) ? v.map(x => inl(x)).join(", ") : inl(v)}</dd>`;
|
|
117
|
+
const row = r => {
|
|
118
|
+
const o = r.owner;
|
|
119
|
+
return `<details class="prow" data-status="${esc(r.status)}">
|
|
120
|
+
<summary><span class="pu"><code>${esc(key(r))}</code>${r.pattern ? ` <span class="pcount">×${num(r.count || 0)}</span>` : ""}</span><span class="pt">${r.target ? esc(r.target) : `<span class="quiet">—</span>`}</span><span class="ptype">${esc(r.type || "")}</span><span class="pst">${chip(r.status)}${ownerOpen(r) ? `<span class="own">Needs you</span>` : ""}</span></summary>
|
|
121
|
+
<dl class="pd">${field("Intent", r.intent)}${r.url ? field("Search traffic", traffic(r.url)) : ""}${field("Other targets", r.secondary)}${field(r.pattern ? "Title template" : "Title", r.title)}${field(r.pattern ? "Description template" : "Description", r.description)}${field(r.pattern ? "H1 template" : "H1", r.h1)}${field("Intro", r.intro)}${field("Schema", r.schema)}${field("Parent", r.parent)}${field("Links to", r.linksTo)}${r.from ? field("Moves from", `${r.from} → ${key(r)}`) : ""}${r.pattern && r.count ? field("Built", `${num(r.status === "built" || r.status === "exists" ? r.count : Number(r.built) || 0)} of ${num(r.count)}`) : ""}${(r.samples || []).length ? `<dt>Examples</dt><dd><ul class="psamples">${r.samples.map(x => `<li><code>${esc(x.url)}</code>${x.title ? ` ${esc(x.title)}` : ""}</li>`).join("")}</ul></dd>` : ""}${o ? `<dt>${o.done === true ? "Done by you" : "Needs you"}</dt><dd>${esc(NEEDS[o.needs] || o.needs || "")}: ${inl(o.what || "")}${o.draft ? (draftHref(o.draft) ? ` · <a href="${esc(draftHref(o.draft))}">Read the draft</a>` : ` · Draft: <code>${esc(o.draft)}</code>`) : ""}</dd>` : ""}${r.finding ? `<dt>Finding</dt><dd><a href="#${esc(r.finding)}">${esc(r.finding)}</a></dd>` : ""}</dl>
|
|
122
|
+
</details>`;
|
|
123
|
+
};
|
|
124
|
+
const present = STATUSES.filter(st => s.byStatus[st]);
|
|
125
|
+
const tableHtml = `<section class="panel plan-pages" aria-labelledby="h-pages">
|
|
126
|
+
<div class="ph"><h2 id="h-pages">Pages</h2><div class="seg" role="group" aria-label="Filter pages by status"><button type="button" class="segb" data-pstatus="all" aria-pressed="true">All</button>${present.map(st => `<button type="button" class="segb" data-pstatus="${st}" aria-pressed="false">${LABEL[st]}<span class="mono">${s.byStatus[st]}</span></button>`).join("")}</div></div>
|
|
127
|
+
<div class="prow-h" aria-hidden="true"><span>Page</span><span>Targets</span><span>Type</span><span>Status</span></div>
|
|
128
|
+
${pages.map(row).join("")}
|
|
129
|
+
</section>`;
|
|
130
|
+
return `<div class="plan">${head}${yesHtml}${treeHtml}${tableHtml}</div>`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const PLAN_CSS = `
|
|
134
|
+
.plan{display:grid;gap:18px}
|
|
135
|
+
.plan-prog{display:grid;gap:8px;margin-top:14px}
|
|
136
|
+
.plan-n{color:var(--mute);font-size:13.5px}.plan-n .n{font:700 34px/1 var(--display);letter-spacing:-.02em;color:var(--ink);margin-right:8px}
|
|
137
|
+
.pbar{height:10px;border-radius:5px;background:var(--line2);overflow:hidden}.pbar i{display:block;height:100%;background:var(--pass)}
|
|
138
|
+
.plan-counts{list-style:none;margin:14px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:8px 18px;font-size:13.5px}
|
|
139
|
+
.plan-counts li{display:inline-flex;align-items:center;gap:6px}.plan-counts b{font:600 13px var(--mono);color:var(--ink)}
|
|
140
|
+
.plan-summary{margin-top:14px;color:var(--ink2);max-width:78ch}
|
|
141
|
+
.plan-fixes{margin-top:10px;color:var(--ink2);font-size:14px}
|
|
142
|
+
.pchip{display:inline-block;font:600 12px/1.6 var(--sans);padding:0 9px;border-radius:999px;border:1px solid transparent;white-space:nowrap}
|
|
143
|
+
.pchip.s-exists{color:var(--mute);border-color:var(--line2)}
|
|
144
|
+
.pchip.s-to-build{color:var(--blue);background:var(--blue-soft)}
|
|
145
|
+
.pchip.s-built{color:var(--b5-ink);background:var(--ok-soft)}
|
|
146
|
+
.pchip.s-to-create{color:var(--ink2);border-color:var(--ink2)}
|
|
147
|
+
.plan-yes ol{margin:12px 0 0;padding-left:22px;display:grid;gap:8px}
|
|
148
|
+
.plan-declined{margin-top:12px;font-size:14px}
|
|
149
|
+
.plan-tree ul{list-style:none;margin:0;padding-left:20px;border-left:1px solid var(--line)}
|
|
150
|
+
.plan-tree h2+ul{padding-left:0;border-left:0;margin-top:10px}
|
|
151
|
+
.plan-tree li{padding:4px 0}.plan-tree li>ul{margin-top:4px}
|
|
152
|
+
.plan-tree code,.pu code,.psamples code{font:500 13px var(--mono);overflow-wrap:anywhere}
|
|
153
|
+
.pcount{font:500 12px var(--mono);color:var(--mute)}
|
|
154
|
+
.plan-pages .ph{flex-wrap:wrap;gap:10px}
|
|
155
|
+
.prow-h,.prow>summary{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,2fr) minmax(0,1.3fr) minmax(150px,auto);gap:12px;align-items:center}
|
|
156
|
+
.prow-h span:last-child{text-align:right}
|
|
157
|
+
.prow-h{margin-top:12px;padding:8px 12px;font-size:12px;font-weight:600;color:var(--mute);border-bottom:1px solid var(--line)}
|
|
158
|
+
.prow{border-bottom:1px solid var(--line)}.prow[hidden]{display:none}
|
|
159
|
+
.prow>summary{padding:12px;cursor:pointer;list-style:none;border-radius:6px}
|
|
160
|
+
.prow>summary::-webkit-details-marker{display:none}
|
|
161
|
+
.prow>summary:hover{background:var(--bg)}
|
|
162
|
+
.prow>summary:focus-visible{outline:2px solid var(--blue);outline-offset:-2px}
|
|
163
|
+
.pu{min-width:0}.pt{min-width:0;color:var(--ink2);font-size:14px;overflow-wrap:anywhere}.ptype{color:var(--mute);font-size:13.5px}
|
|
164
|
+
.pst{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
|
|
165
|
+
.pd{display:grid;grid-template-columns:150px minmax(0,1fr);gap:6px 16px;margin:0;padding:4px 12px 16px;font-size:14px}
|
|
166
|
+
.pd dt{color:var(--mute);font-weight:600;font-size:12.5px;padding-top:2px}.pd dd{margin:0;overflow-wrap:anywhere}
|
|
167
|
+
.psamples{list-style:none;margin:0;padding:0;display:grid;gap:4px}
|
|
168
|
+
@media (max-width:560px){.prow-h{display:none}.prow>summary{grid-template-columns:minmax(0,1fr);gap:4px}.pst{justify-content:flex-start}.pd{grid-template-columns:minmax(0,1fr);gap:2px}.pd dt{margin-top:8px}}
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
// The audit findings setup fixes in code after approval (plan.alsoFixes), as one sentence.
|
|
172
|
+
function fixesLine(plan, count, list, html = true) {
|
|
173
|
+
const ids = Array.isArray(plan.alsoFixes) ? plan.alsoFixes : [];
|
|
174
|
+
if (!ids.length) return "";
|
|
175
|
+
const what = `${count(ids.length)} audit finding${ids.length === 1 ? "" : "s"} in code`;
|
|
176
|
+
const text =
|
|
177
|
+
plan.status === "built"
|
|
178
|
+
? `Setup also fixed ${what}: ${list(ids)}`
|
|
179
|
+
: `After the build, setup also fixes ${what}: ${list(ids)}`;
|
|
180
|
+
return html ? `<p class="plan-fixes">${text}</p>` : `${text}.`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Escaped like the rest of the report: mdSafe keeps `code` spans as inl does and makes URLs code spans; cellMd also
|
|
184
|
+
// escapes a table cell's pipes and line breaks.
|
|
185
|
+
const cell = v => cellMd(mdSafe(Array.isArray(v) ? v.join(", ") : v));
|
|
186
|
+
const item = (id, what) => `${id ? `${noteMd(id)}: ` : ""}${mdSafe(what)}`;
|
|
187
|
+
|
|
188
|
+
export function planMarkdown(plan) {
|
|
189
|
+
const pages = Array.isArray(plan?.pages) ? plan.pages : [];
|
|
190
|
+
const s = planStats(plan);
|
|
191
|
+
const L = ["## SEO plan", ""];
|
|
192
|
+
L.push(
|
|
193
|
+
`Status: ${noteMd(PLAN_LABEL[plan.status] || plan.status || "?")}${plan.approvedOn ? ` (approved ${noteMd(plan.approvedOn)})` : ""} · Progress: ${s.progress}% · ${
|
|
194
|
+
STATUSES.filter(st => s.byStatus[st])
|
|
195
|
+
.map(st => `${s.byStatus[st]} ${LABEL[st].toLowerCase()}`)
|
|
196
|
+
.join(", ") || "no pages"
|
|
197
|
+
}${s.ownerOpen ? ` · ${s.ownerOpen} need you` : ""}`,
|
|
198
|
+
"",
|
|
199
|
+
);
|
|
200
|
+
if (plan.summary) L.push(mdSafe(plan.summary), "");
|
|
201
|
+
const fixes = fixesLine(plan, String, ids => ids.join(", "), false);
|
|
202
|
+
if (fixes) L.push(mdSafe(fixes), "");
|
|
203
|
+
const yes = [
|
|
204
|
+
...(plan.yes || []).filter(yesOpen).map(y => `- ${item(y.id, y.what)}${y.why ? ` (${mdSafe(y.why)})` : ""}`),
|
|
205
|
+
...pages.filter(r => ownerOpen(r) && r.owner.needs === "yes").map(r => `- ${item(key(r), r.owner.what || "")}`),
|
|
206
|
+
];
|
|
207
|
+
if (yes.length)
|
|
208
|
+
L.push("### Needs your yes", "", "Each needs its own yes; approving the plan doesn't cover them.", "", ...yes, "");
|
|
209
|
+
for (const y of (plan.yes || []).filter(y => y.declined === true)) L.push(`Declined: ${item(y.id, y.what)}`);
|
|
210
|
+
for (const r of pages.filter(r => r.owner && r.owner.declined === true))
|
|
211
|
+
L.push(`Declined: ${item(key(r), r.owner.what || "")}`);
|
|
212
|
+
if ((plan.yes || []).some(y => y.declined === true) || pages.some(r => r.owner && r.owner.declined === true))
|
|
213
|
+
L.push("");
|
|
214
|
+
if (!pages.length) {
|
|
215
|
+
L.push("No pages in this plan yet.", "");
|
|
216
|
+
return L;
|
|
217
|
+
}
|
|
218
|
+
L.push(
|
|
219
|
+
"| Page | Type | Status | Target | Title | Description | H1 | Schema | Parent | Needs you |",
|
|
220
|
+
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |",
|
|
221
|
+
);
|
|
222
|
+
for (const r of pages) {
|
|
223
|
+
const page = r.pattern ? `${r.pattern} ×${r.count || 0}` : r.url;
|
|
224
|
+
const owner = ownerOpen(r)
|
|
225
|
+
? `${NEEDS[r.owner.needs] || r.owner.needs}: ${r.owner.what || ""}${r.owner.draft ? ` (draft: ${r.owner.draft})` : ""}`
|
|
226
|
+
: "";
|
|
227
|
+
L.push(
|
|
228
|
+
`| ${cell(page)} | ${cell(r.type)} | ${cell(LABEL[r.status] || r.status)} | ${cell(r.target)} | ${cell(r.title)} | ${cell(r.description)} | ${cell(r.h1)} | ${cell(r.schema)} | ${cell(r.parent)} | ${cell(owner)} |`,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
L.push("");
|
|
232
|
+
const intros = pages.filter(r => r.intro);
|
|
233
|
+
if (intros.length)
|
|
234
|
+
L.push(
|
|
235
|
+
"Intros for new pages (approving the plan approves these words):",
|
|
236
|
+
"",
|
|
237
|
+
...intros.map(r => `- ${item(key(r), r.intro)}`),
|
|
238
|
+
"",
|
|
239
|
+
);
|
|
240
|
+
return L;
|
|
241
|
+
}
|