seo-supervisor 1.2.0 → 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.
Files changed (207) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +16 -3
  4. package/CHANGELOG.md +430 -0
  5. package/NOTICE +7 -0
  6. package/README.md +230 -25
  7. package/agents/seo-auditor.md +16 -0
  8. package/agents/seo-reviewer.md +16 -0
  9. package/bin/agents.mjs +194 -29
  10. package/bin/extras.mjs +422 -0
  11. package/bin/prompt.mjs +34 -14
  12. package/bin/seo-supervisor.mjs +386 -53
  13. package/commands/seo-audit.md +29 -3
  14. package/commands/seo-brief.md +28 -0
  15. package/commands/seo-connect.md +27 -0
  16. package/commands/seo-fix.md +24 -3
  17. package/commands/seo-grow.md +26 -0
  18. package/commands/seo-launch.md +17 -3
  19. package/commands/seo-review.md +13 -1
  20. package/commands/seo-rewrite.md +25 -0
  21. package/commands/seo-setup.md +17 -1
  22. package/commands/seo-watch.md +28 -0
  23. package/hooks/hooks.json +117 -0
  24. package/package.json +20 -7
  25. package/skills/seo-supervisor/NOTICE +7 -0
  26. package/skills/seo-supervisor/SKILL.md +302 -21
  27. package/skills/seo-supervisor/audience.md +61 -0
  28. package/skills/seo-supervisor/examples/drafts/security.md +41 -0
  29. package/skills/seo-supervisor/examples/hooks/README.md +28 -0
  30. package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
  31. package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
  32. package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
  33. package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
  34. package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
  35. package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
  36. package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
  37. package/skills/seo-supervisor/examples/sample-audit.json +94 -2
  38. package/skills/seo-supervisor/examples/sample-report.html +111 -61
  39. package/skills/seo-supervisor/examples/sample-report.md +147 -44
  40. package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
  41. package/skills/seo-supervisor/examples/snippets.md +648 -1
  42. package/skills/seo-supervisor/grow.md +342 -0
  43. package/skills/seo-supervisor/og-images.md +85 -0
  44. package/skills/seo-supervisor/page-types.md +124 -0
  45. package/skills/seo-supervisor/planning.md +19 -7
  46. package/skills/seo-supervisor/profile-template.md +41 -0
  47. package/skills/seo-supervisor/report-format.md +177 -10
  48. package/skills/seo-supervisor/rewrite.md +59 -0
  49. package/skills/seo-supervisor/rules/ai-search.md +65 -12
  50. package/skills/seo-supervisor/rules/content.md +33 -9
  51. package/skills/seo-supervisor/rules/crawl-index.md +33 -6
  52. package/skills/seo-supervisor/rules/internal-linking.md +49 -6
  53. package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
  54. package/skills/seo-supervisor/rules/media.md +13 -1
  55. package/skills/seo-supervisor/rules/metadata.md +41 -9
  56. package/skills/seo-supervisor/rules/performance.md +50 -5
  57. package/skills/seo-supervisor/rules/rendering.md +39 -2
  58. package/skills/seo-supervisor/rules/search-intent.md +32 -0
  59. package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
  60. package/skills/seo-supervisor/rules/structured-data.md +37 -14
  61. package/skills/seo-supervisor/rules/trust-security.md +25 -2
  62. package/skills/seo-supervisor/rules/urls.md +10 -2
  63. package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
  64. package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
  65. package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
  66. package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
  67. package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
  68. package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
  69. package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
  70. package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
  71. package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
  72. package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
  73. package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
  74. package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
  75. package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
  76. package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
  77. package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
  78. package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
  79. package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
  80. package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
  81. package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
  82. package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
  83. package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
  84. package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
  85. package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
  86. package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
  87. package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
  88. package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
  89. package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
  90. package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
  91. package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
  92. package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
  93. package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
  94. package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
  95. package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
  96. package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
  97. package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
  98. package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
  99. package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
  100. package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
  101. package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
  102. package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
  103. package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
  104. package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
  105. package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
  106. package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
  107. package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
  108. package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
  109. package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
  110. package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
  111. package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
  112. package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
  113. package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
  114. package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
  115. package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
  116. package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
  117. package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
  118. package/skills/seo-supervisor/scripts/google.mjs +1341 -0
  119. package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
  120. package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
  121. package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
  122. package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
  123. package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
  124. package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
  125. package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
  126. package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
  127. package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
  128. package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
  129. package/skills/seo-supervisor/scripts/guard.mjs +74 -0
  130. package/skills/seo-supervisor/scripts/images.mjs +408 -0
  131. package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
  132. package/skills/seo-supervisor/scripts/issues.mjs +217 -0
  133. package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
  134. package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
  135. package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
  136. package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
  137. package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
  138. package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
  139. package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
  140. package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
  141. package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
  142. package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
  143. package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
  144. package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
  145. package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
  146. package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
  147. package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
  148. package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
  149. package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
  150. package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
  151. package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
  152. package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
  153. package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
  154. package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
  155. package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
  156. package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
  157. package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
  158. package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
  159. package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
  160. package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
  161. package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
  162. package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
  163. package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
  164. package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
  165. package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
  166. package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
  167. package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
  168. package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
  169. package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
  170. package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
  171. package/skills/seo-supervisor/scripts/osm.mjs +359 -0
  172. package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
  173. package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
  174. package/skills/seo-supervisor/scripts/report/client.js +37 -0
  175. package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
  176. package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
  177. package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
  178. package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
  179. package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
  180. package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
  181. package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
  182. package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
  183. package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
  184. package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
  185. package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
  186. package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
  187. package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
  188. package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
  189. package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
  190. package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
  191. package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
  192. package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
  193. package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
  194. package/skills/seo-supervisor/scripts/report/styles.css +223 -0
  195. package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
  196. package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
  197. package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
  198. package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
  199. package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
  200. package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
  201. package/skills/seo-supervisor/site-types/content.md +34 -1
  202. package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
  203. package/skills/seo-supervisor/site-types/local-business.md +96 -6
  204. package/skills/seo-supervisor/site-types/services.md +46 -0
  205. package/skills/seo-supervisor/site-types/tools.md +3 -3
  206. package/skills/seo-supervisor/strategy.md +232 -0
  207. package/skills/seo-supervisor/troubleshooting.md +56 -0
@@ -0,0 +1,224 @@
1
+ // @ts-check
2
+ // The Overview tab, action first. Information panels belong on the topic tabs (render-report.mjs).
3
+ import { SEV, bandOf, OWN_SCORE } from "../lib/score.mjs";
4
+ import { passes } from "../checks/speed.mjs";
5
+ import { SEV_LABEL, ICON, dot, esc, inl, num, obj, plural } from "./format.mjs";
6
+ import { needsYou } from "./model.mjs";
7
+ import { byPath } from "./traffic.mjs";
8
+ import { periodOf } from "./sources.mjs";
9
+
10
+ // Fix first and Needs you, for the page and the Markdown. Needs you takes what /seo-fix won't change unasked: fixBy:
11
+ // "owner" findings, open decisions and findings with a decision. Fix first takes the rest, so nothing is in both. Both
12
+ // sort by severity, then by Search Console clicks on the finding's pages.
13
+ export const isOwnersCall = (f, decisions = []) =>
14
+ needsYou(f) ||
15
+ f.status === "needs-decision" ||
16
+ f.severity === "needs-decision" ||
17
+ decisions.some(d => d.id && d.id === f.id);
18
+ export function actions({ raw, open, decisions }) {
19
+ const clicks = f =>
20
+ Math.max(
21
+ 0,
22
+ ...(Array.isArray(f.evidence) ? f.evidence : []).map(e => Number(byPath(raw.traffic, e?.url)?.clicks) || 0),
23
+ );
24
+ const order = list => list.sort((a, b) => SEV.indexOf(a.sev) - SEV.indexOf(b.sev) || b.clicks - a.clicks);
25
+ const item = f => ({ id: f.id, title: f.title, sev: f.severity, f, clicks: clicks(f) });
26
+ const mine = f => isOwnersCall(f, decisions) && f.status !== "wont-fix"; // a won't-fix is decided: in neither list
27
+ const code = order(open.filter(f => !mine(f) && f.status !== "wont-fix").map(item)),
28
+ serious = code.filter(x => x.sev === "blocker" || x.sev === "high");
29
+ const own = open.filter(mine),
30
+ asked = decisions.filter(d => !own.some(f => f.id && f.id === d.id));
31
+ const yours = order([
32
+ ...own.map(item),
33
+ ...asked.map(d => ({ id: d.id, title: d.question, sev: "needs-decision", d, clicks: 0 })),
34
+ ]);
35
+ return {
36
+ fixFirst: (serious.length ? serious : code.slice(0, 3)).slice(0, 5),
37
+ needsYou: yours.slice(0, 3),
38
+ yours,
39
+ tasks: own.filter(f => !decisions.some(d => d.id === f.id)),
40
+ };
41
+ }
42
+ // A closed site (over half the pages noindex) is read from the crawler's note, the only place the audit file keeps
43
+ // it, so match any new wording of that note here.
44
+ const closedNote = notes =>
45
+ (Array.isArray(notes) ? notes : []).map(n => /^(\d+)% of pages are noindex\b/.exec(String(n))?.[1]).find(Boolean);
46
+ export const scopeText = ({ run, overall, notChecked, notes }) => {
47
+ const closed = closedNote(notes);
48
+ return `Checked ${run.pagesCrawled != null ? `${plural(Number(run.pagesCrawled) || 0, "page")} against ` : ""}${plural(overall?.rules || 0, "rule")}${closed ? ` · ${closed}% of pages are noindex, so their page checks were skipped: before launch, re-run with --ignore-noindex` : ""} · ${notChecked.length ? `${plural(notChecked.length, "check")} couldn't run` : "every planned check ran"}: see`;
49
+ };
50
+ // Clicks are the property's total, else the pages' sum; Core Web Vitals use origin data, else the first page's.
51
+ export function keyNumbers({ raw }) {
52
+ const t = obj(raw.traffic),
53
+ tot = Number(obj(raw.siteTotals)?.clicks),
54
+ sum = t ? Object.values(t).reduce((s, x) => s + (Number(x?.clicks) || 0), 0) : 0;
55
+ const clicks = tot > 0 ? tot : t && Object.keys(t).length ? sum : null;
56
+ const s = (Array.isArray(raw.speed?.samples) ? raw.speed.samples : []).filter(obj),
57
+ v = s.find(x => obj(x.origin))?.origin || s.find(x => obj(x.field))?.field;
58
+ const period = periodOf(raw, tot > 0 ? "siteTotals" : "traffic"); // from the clicks' own source
59
+ return {
60
+ clicks,
61
+ period: period ? String(period).toLowerCase() : "",
62
+ cwv: v && Number.isFinite(v.lcp) ? (passes(v) ? "Pass" : "Fail") : null,
63
+ strategy: raw.speed?.strategy || "mobile",
64
+ };
65
+ }
66
+
67
+ // The health score is a local formula, and the text says so.
68
+ export const SCORE_HOW = `Every checked rule is worth 10 points. A rule that passes, or whose findings are all fixed, earns 10. A rule with open findings earns by its worst one: low 8, medium or decision 6, high 3, blocker 0. The score is the share of points earned. Each open blocker caps it: one at 59, two at 49, three at 39. While any finding is open, except one marked won't fix, it stops at 99: 100 means nothing is left to fix. While a blocker is open, the panel also shows the score you reach once it is fixed. Area scores use the same rules within each area. This is ${OWN_SCORE}: it counts only the rules this audit checked, and search engines don't use it.`;
69
+
70
+ function scoreScale(v) {
71
+ /** @type {[number, number, string][]} */
72
+ const segs = [
73
+ [0, 40, "b1"],
74
+ [40, 60, "b2"],
75
+ [60, 75, "b3"],
76
+ [75, 90, "b4"],
77
+ [90, 100, "b5"],
78
+ ];
79
+ return `<div class="scale" role="img" aria-label="Score ${v} on a 0 to 100 scale: 0–39 critical, 40–59 poor, 60–74 fair, 75–89 good, 90–100 excellent">
80
+ <div class="track">${segs.map(([a, b, c]) => `<span class="${c}" style="flex:${b - a}"></span>`).join("")}</div>
81
+ <span class="marker" style="left:${v}%"><b>${v}</b></span>
82
+ <div class="ticks">${[0, 40, 60, 75, 90, 100].map(t => `<span style="left:${t}%">${t}</span>`).join("")}</div>
83
+ </div>`;
84
+ }
85
+ function unlockHtml({ unlock, overall, openBlockers }, delta) {
86
+ if (!unlock) return "";
87
+ const [, name, cls] = bandOf(unlock.value);
88
+ const ids = list => list.map(f => `<a href="#${esc(f.id)}">${esc(f.id)}</a>`).join(", ");
89
+ const owner = openBlockers.filter(needsYou),
90
+ agent = openBlockers.filter(f => !needsYou(f));
91
+ const who = [
92
+ owner.length &&
93
+ `${ids(owner)} need${owner.length === 1 ? "s" : ""} you: the agent won't change ${owner.length === 1 ? "it" : "them"} without your go-ahead.`,
94
+ agent.length && `${ids(agent)} can be fixed with <code>/seo-fix</code>.`,
95
+ ]
96
+ .filter(Boolean)
97
+ .join(" ");
98
+ return `<div class="unlock">
99
+ <p class="u-k">Fix ${openBlockers.length === 1 ? "the blocker" : `the ${openBlockers.length} blockers`} and the score rises to</p>
100
+ <p class="u-v"><span class="from">${overall.value}</span><span class="arrow" aria-hidden="true">→</span><span class="to ${cls}-t">${unlock.value}</span><span class="chip ${cls}">${name}</span></p>
101
+ ${delta && delta.inUnlock ? `<p class="u-s delta ${delta.dir}">${delta.html}.</p>` : ""}
102
+ ${who ? `<p class="u-s">${who}</p>` : ""}
103
+ </div>`;
104
+ }
105
+
106
+ /** m is the model from model.mjs, with raw. */
107
+ export function overviewHtml(m) {
108
+ const { run, overall, deltaOf, countSev, open, fixed, findings, verdict, impact, areas } = m;
109
+ if (!overall)
110
+ return `<section class="panel empty-state"><h2>Nothing to score</h2><p>This file has no findings or passed rules. Run the audit to fill it.</p></section>`;
111
+ const [, bandName, bandCls] = bandOf(overall.value);
112
+ const capLine = overall.cap
113
+ ? `${plural(overall.blockers, "open blocker")} hold${overall.blockers === 1 ? "s" : ""} the score at ${overall.cap} until fixed.`
114
+ : `${overall.passing} of ${overall.rules} checked rules pass in full.`;
115
+ const delta = deltaOf();
116
+ const sevBar = SEV.map(s => [s, countSev(s)]).filter(([, n]) => n);
117
+ const totalOpen = open.length;
118
+ const { fixFirst, needsYou: yours, yours: allYours } = actions(m),
119
+ keys = keyNumbers(m);
120
+ // A row links to the finding's card, or to the Decisions tab for a decision no finding carries: its id (D-1) is no
121
+ // anchor on the page.
122
+ const row = x =>
123
+ `<a href="#${esc(x.d && !findings.some(f => f.id === x.id) ? "p-decisions" : x.id || "p-decisions")}">${dot(x.sev)}<span class="sev-t">${SEV_LABEL[x.sev]}</span><span class="t">${inl(x.title)}</span><span class="c">${esc(x.f?.category || "")}</span>${ICON.arrow}</a>`;
124
+ const stat = (h, n, rest = "") =>
125
+ `\n <div class="stat">\n <h3>${h}</h3>\n <p class="stat-n"><span class="n">${n}</span>${rest}</p>`;
126
+ return `
127
+ <div class="ov-top">
128
+ <div class="ov-left">
129
+ <section class="panel score-panel" aria-labelledby="h-score">
130
+ <h2 id="h-score">SEO health score</h2>
131
+ <p class="big ${bandCls}-t"><span class="n">${overall.value}</span><span class="of">/100</span></p>
132
+ <p class="band"><span class="chip ${bandCls}">${bandName}</span><span class="verdict">${esc(verdict)}</span></p>
133
+ ${scoreScale(overall.value)}
134
+ <p class="cap">${esc(capLine)}</p>
135
+ ${unlockHtml(m, delta)}
136
+ ${delta && !delta.inUnlock ? `<p class="delta ${delta.dir}">${delta.html}</p>` : ""}
137
+ <details class="how"><summary>How this score works</summary>
138
+ <p>${SCORE_HOW}</p>
139
+ </details>
140
+ </section>
141
+ ${
142
+ fixFirst.length
143
+ ? `<section class="panel fixfirst" aria-labelledby="h-first">
144
+ <div class="ph"><h2 id="h-first">Fix first</h2><a class="link" href="#p-findings">All findings ${ICON.arrow}</a></div>
145
+ <p class="sub">What the agent can fix in code. Each line fixes one.</p>
146
+ <ol>${fixFirst.map(x => `<li>${row(x)}${x.id ? `<p class="next"><code>/seo-fix ${esc(x.id)}</code></p>` : ""}</li>`).join("")}</ol>
147
+ </section>`
148
+ : ""
149
+ }
150
+ ${
151
+ yours.length
152
+ ? `<section class="panel fixfirst needsyou" aria-labelledby="h-you">
153
+ <div class="ph"><h2 id="h-you">Needs you</h2><a class="link" href="#p-decisions">All ${allYours.length} in Decisions ${ICON.arrow}</a></div>
154
+ <p class="sub">Your call, your accounts or your go-ahead: the agent won't change these without you.</p>
155
+ <ol>${yours.map(x => `<li>${row(x)}</li>`).join("")}</ol>
156
+ </section>`
157
+ : ""
158
+ }
159
+ </div>
160
+ <div class="ov-right">
161
+ <section class="panel factors" aria-labelledby="h-factors">
162
+ <div class="ph"><h2 id="h-factors">What's moving your score</h2><span class="sub">Points lost, biggest first</span></div>
163
+ <ol class="area-list">${(() => {
164
+ const maxPts = Math.max(impact.cap, ...impact.rows.map(x => x.pts), 1);
165
+ const bar = pts =>
166
+ `<span class="meter" aria-hidden="true"><i style="width:${Math.max(4, (100 * pts) / maxPts)}%"></i></span>`;
167
+ const rows = [];
168
+ if (impact.cap > 0)
169
+ rows.push(`<li><a class="area" href="#p-findings" data-sev="blocker">${dot("blocker")}
170
+ <span class="an"><b>Blocker cap</b><span class="reason">Lifted once the ${overall.blockers === 1 ? "blocker is" : "blockers are"} fixed</span></span>
171
+ ${bar(impact.cap)}<span class="as">−${impact.cap}<small>pts</small></span></a></li>`);
172
+ for (const { a, pts } of impact.rows) {
173
+ const line = a.top.length
174
+ ? `${inl(a.top[0].title)}${a.top.length > 1 ? ` <span class="more">+${a.top.length - 1} more</span>` : ""}`
175
+ : "All checks pass";
176
+ rows.push(`<li><a class="area" href="#p-findings" data-area="${esc(a.name)}">${a.worst ? dot(a.worst) : `<i class="dot d-pass" aria-hidden="true"></i>`}
177
+ <span class="an"><b>${esc(a.name)} <span class="ascore">${a.value}/100</span></b><span>${line}</span></span>
178
+ ${bar(pts)}<span class="as">${pts ? `−${pts}` : "&lt;1"}<small>pts</small></span></a></li>`);
179
+ }
180
+ const full = areas.filter(a => a.value === 100);
181
+ if (full.length) {
182
+ const fx = full.reduce((t, a) => t + a.fixedHere, 0);
183
+ rows.push(`<li><a class="area" href="#p-passed"><i class="dot d-pass" aria-hidden="true"></i>
184
+ <span class="an"><b>${plural(full.length, "area")} pass in full</b><span>${esc(full.map(a => a.name).join(", "))}${fx ? ` · ${fx} fixed this run` : ""}</span></span>
185
+ <span class="meter" aria-hidden="true"></span><span class="as ok">0<small>pts</small></span></a></li>`);
186
+ }
187
+ return rows.join("");
188
+ })()}</ol>
189
+ </section>
190
+ <p class="scope">${esc(scopeText(m))} <a href="#p-limits">Limits</a></p>
191
+ <section class="panel stats" aria-labelledby="h-keys">
192
+ <h2 id="h-keys" class="sr">Key numbers</h2>${
193
+ run.pagesCrawled != null
194
+ ? `${stat("Pages checked", num(Number(run.pagesCrawled) || 0))}
195
+ </div>`
196
+ : ""
197
+ }${stat("Open issues", totalOpen, totalOpen ? "" : " · nothing open")}
198
+ ${
199
+ totalOpen
200
+ ? `<div class="stack" role="img" aria-label="${sevBar.map(([sv, n]) => `${n} ${SEV_LABEL[sv]}`).join(", ")}">${sevBar.map(([sv, n]) => `<span class="s-${sv}" style="flex:${n}"></span>`).join("")}</div>
201
+ <ul class="legend">${sevBar.map(([sv, n]) => `<li>${dot(sv)}<span>${SEV_LABEL[sv]}</span><b>${n}</b></li>`).join("")}</ul>`
202
+ : ""
203
+ }
204
+ </div>${stat("Fixed this run", fixed.length, ` of ${findings.length}`)}
205
+ <div class="stack" role="img" aria-label="${fixed.length} fixed, ${open.length} still open"><span class="s-fixed" style="flex:${fixed.length || 0.0001}"></span><span class="s-rest" style="flex:${open.length || 0.0001}"></span></div>
206
+ <p class="quiet">${fixed.length ? `${num(open.length)} still open` : "Run /seo-fix to start"}</p>
207
+ </div>${
208
+ keys.clicks != null
209
+ ? `${stat("Clicks from Google", num(keys.clicks))}
210
+ <p class="quiet">Search Console${keys.period ? `, ${esc(keys.period)}` : ""}</p>
211
+ </div>`
212
+ : ""
213
+ }${
214
+ keys.cwv
215
+ ? `${stat("Core Web Vitals", keys.cwv)}
216
+ <p class="quiet">Real visitors, ${esc(keys.strategy)}</p>
217
+ </div>`
218
+ : ""
219
+ }
220
+ </section>
221
+ </div>
222
+ </div>
223
+ `;
224
+ }
@@ -0,0 +1,127 @@
1
+ // @ts-check
2
+ // The report page: one self-contained file with its fonts, styles and script inlined.
3
+ import { createHash } from "node:crypto";
4
+ import { readFileSync, existsSync } from "node:fs";
5
+ import { planStats, planHtml, PLAN_CSS } from "../report-plan.mjs";
6
+ import { VERSION } from "../update-check.mjs";
7
+ import { esc, inl, link, num, fmtDate, firstSentence } from "./format.mjs";
8
+ import { cardsHtml } from "./panel.mjs";
9
+
10
+ // Bundled woff2 fonts (SIL OFL), inlined so the report stays a single offline file.
11
+ const FONTS = [
12
+ ["Geist", "geist.woff2", "100 900"],
13
+ ["Geist Mono", "geist-mono.woff2", "100 900"],
14
+ ["Bricolage Grotesque", "bricolage-grotesque.woff2", "200 800"],
15
+ ];
16
+ const FONT_FACES = FONTS.map(([family, file, weight]) => {
17
+ const path = new URL("../fonts/" + file, import.meta.url);
18
+ if (!existsSync(path)) return "";
19
+ return `@font-face{font-family:"${family}";src:url(data:font/woff2;base64,${readFileSync(path).toString("base64")}) format("woff2");font-weight:${weight};font-style:normal;font-display:swap}`;
20
+ }).join("\n");
21
+
22
+ // client.js holds a __DEFAULT_TAB__ placeholder. Neither file can carry comments: every byte goes into the report.
23
+ const CSS = readFileSync(new URL("./styles.css", import.meta.url), "utf8");
24
+ // LF line ends, as the browser reads them, so the script's hash matches even in a CRLF checkout.
25
+ const CLIENT_JS = readFileSync(new URL("./client.js", import.meta.url), "utf8").replace(/\r\n?/g, "\n");
26
+ // Applies a saved light theme before the first paint.
27
+ const HEAD_JS =
28
+ "(function(h){h.classList.add('js');try{if(localStorage.getItem('seo-report-theme')==='light')h.dataset.theme='light'}catch(e){}})(document.documentElement)";
29
+ // Only the two hashed scripts run, styles are inline, fonts are data: URIs and nothing is fetched, so an injected
30
+ // script or a javascript: link can't run.
31
+ const hash = s => `'sha256-${createHash("sha256").update(s).digest("base64")}'`;
32
+ const csp = scripts =>
33
+ `default-src 'none'; script-src ${scripts.map(hash).join(" ")}; style-src 'unsafe-inline'; font-src data:; base-uri 'none'; form-action 'none'`;
34
+
35
+ /**
36
+ * Takes the model (model.mjs) with raw and mdFile, then each tab's HTML as a function and every tab's panels
37
+ * (report/panel.mjs byTab).
38
+ */
39
+ export function pageHtml(
40
+ { raw, site, run, findings, fixed, passed, notChecked, mdFile },
41
+ {
42
+ plan,
43
+ diff,
44
+ overviewHtml,
45
+ diffHtml,
46
+ trafficFor,
47
+ findingsHtml,
48
+ decisionsHtml,
49
+ decisionCount,
50
+ changesHtml,
51
+ passedHtml,
52
+ limitsHtml,
53
+ topics,
54
+ tabs: panels,
55
+ },
56
+ ) {
57
+ // Action first (Overview, Findings, Decisions), then the data, then the record (Changes, Passed, Limits).
58
+ // markdown.mjs keeps this order.
59
+ const tabs = [
60
+ ["overview", "Overview", null],
61
+ ["findings", "Findings", findings.length],
62
+ ["decisions", "Decisions", decisionCount],
63
+ ...topics.map(([id, label]) => [id, label, null]),
64
+ ...(diff || panels.since ? [["diff", "Since last audit", diff ? (diff.regressions || []).length : null]] : []),
65
+ ["changes", "Changes", fixed.length],
66
+ ["passed", "Passed", passed.length + fixed.length],
67
+ ["limits", "Limits", notChecked.length],
68
+ ];
69
+ if (plan) tabs.splice(plan.status === "proposed" ? 0 : 1, 0, ["plan", "Plan", planStats(plan).rows]);
70
+ const DEFAULT_TAB = tabs[0][0];
71
+ const PANELS = {
72
+ overview: overviewHtml,
73
+ diff: () => `${diff ? diffHtml() : ""}${cardsHtml(panels.since)}`,
74
+ plan: () => planHtml(plan, { esc, inl, num, traffic: u => trafficFor(u, true) }),
75
+ findings: () => findingsHtml(cardsHtml(panels.findings)),
76
+ decisions: decisionsHtml,
77
+ changes: changesHtml,
78
+ passed: passedHtml,
79
+ limits: () => limitsHtml(cardsHtml(panels.limits)),
80
+ ...Object.fromEntries(
81
+ topics.map(([id]) => [
82
+ id,
83
+ () =>
84
+ `<p class="quiet topic-note">Information only: nothing on this tab changes the score.</p>${cardsHtml(panels[id])}`,
85
+ ]),
86
+ ),
87
+ };
88
+ const metaBits = [
89
+ site.url && link(site.url, esc(String(site.url).replace(/^https?:\/\//, ""))),
90
+ run.pagesCrawled != null && `${num(run.pagesCrawled)} pages crawled`,
91
+ esc(fmtDate(run.date)),
92
+ run.mode === "fix" && "Includes fixes",
93
+ ].filter(Boolean);
94
+
95
+ // The hash covers the script's text as it sits between its tags, leading newline included.
96
+ const JS = "\n" + CLIENT_JS.replace("__DEFAULT_TAB__", DEFAULT_TAB);
97
+
98
+ return `<!doctype html>
99
+ <html lang="en">
100
+ <head>
101
+ <meta charset="utf-8">
102
+ <meta http-equiv="Content-Security-Policy" content="${csp([HEAD_JS, JS])}">
103
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
104
+ <meta name="robots" content="noindex, nofollow">
105
+ <meta name="color-scheme" content="dark light">
106
+ <title>SEO report · ${esc(site.name)}</title>
107
+ <script>${HEAD_JS}</script>
108
+ <style>${FONT_FACES}
109
+
110
+ ${CSS}${plan ? PLAN_CSS : ""}</style>
111
+ </head>
112
+ <body>
113
+ <header class="top"><div class="wrap">
114
+ <div class="title-row"><h1>${esc(site.name)}</h1><button class="theme-btn" type="button" hidden><svg class="i-sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg><svg class="i-moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"/></svg><span class="tl">Light</span></button></div>
115
+ <p class="meta"><span>SEO report</span>${metaBits.map(b => `<span>${b}</span>`).join("")}</p>
116
+ ${raw.summary ? (raw.summary.length <= 300 ? `<p class="lede">${inl(raw.summary)}</p>` : `<div class="lede"><p>${inl(firstSentence(raw.summary))}</p><details class="lede-more"><summary>Full summary</summary><p>${inl(raw.summary.slice(firstSentence(raw.summary).length).trim())}</p></details></div>`) : ""}
117
+ <nav class="tabs" role="tablist" aria-label="Report sections">${tabs.map(([id, label, n], i) => `<button class="tab" role="tab" id="t-${id}" data-tab="${id}" aria-controls="p-${id}" aria-selected="${i === 0}" tabindex="${i === 0 ? 0 : -1}">${label}${n != null ? `<span class="cnt">${n}</span>` : ""}</button>`).join("")}</nav>
118
+ </div></header>
119
+ <main class="wrap">
120
+ ${tabs.map(([id, label]) => `<section class="tp" id="p-${id}" role="tabpanel" aria-labelledby="t-${id}" data-title="${label}"${id === DEFAULT_TAB ? "" : " hidden"}>${PANELS[id]()}</section>`).join("\n ")}
121
+ </main>
122
+ <footer><div class="wrap"><span>${mdFile ? `Full detail for every finding: <code>${esc(mdFile)}</code> in the same folder.` : ""}</span><span>Generated by SEO Supervisor ${VERSION}${run.auditor && run.auditor !== "seo-supervisor" ? ` · ${esc(run.auditor)}` : ""} · ${esc(fmtDate(run.date))}</span></div></footer>
123
+ <script>${JS}</script>
124
+ </body>
125
+ </html>
126
+ `;
127
+ }
@@ -0,0 +1,172 @@
1
+ // @ts-check
2
+ // Topic-tab panels, each built once as a view model and drawn by panelHtml and panelMd, so the page and the Markdown
3
+ // can't drift apart. Escaping happens here, the same way for every panel. A panel with nothing to show is null.
4
+ import { cellMd, esc, inl, mdSafe, noteCode, noteMd, num } from "./format.mjs";
5
+
6
+ /**
7
+ * Text: a string (escaped), { code } (a code span), { b } (bold), { id } (a finding's id: a link on the page, plain in
8
+ * the Markdown), { inl } (report text with `code` in it: inl on the page, mdSafe in the Markdown), { html, md }
9
+ * (already written for each, where the two differ), or a list of these, joined.
10
+ * @typedef {any} Text
11
+ * A block, one of:
12
+ * { quiet } a quiet line (outside a collapsed panel), a paragraph in the Markdown
13
+ * { p } a paragraph
14
+ * { rows, cap, bold } a list of [key, value?, sep?] rows: "- key value" in the Markdown (sep, " " unless
15
+ * given, goes between; bold: the key is bold there); on the page a value left out has no
16
+ * <span>; cap: the page shows that many, the Markdown all
17
+ * { head, align, rows, cap } a table (align: the Markdown's alignment row, like "---:")
18
+ * { sub, heading, blocks } a list inside a panel: a plain <details> on the page (sub its summary), ### in the
19
+ * Markdown
20
+ * { panel } a whole panel after this one's lines: its own collapsed panel on the page, ### in the
21
+ * Markdown
22
+ * { page } a paragraph only the page shows (the Markdown lists everything, so it needs no "more in")
23
+ * { md }, { html, md } lines only the Markdown has; or markup and lines already written for each (a credit
24
+ * with a link)
25
+ * any block with mdOnly left off the page (the page shows the first few, the Markdown all)
26
+ * @typedef {any} Block
27
+ * @typedef {{ cls?: string, title: string, summary?: Text, blocks: (Block | false | null | undefined | "" | 0)[] } | null} Panel
28
+ * cls: the collapsed panel's hook class (left out: the blocks sit on the page as they are); summary: the page's
29
+ * summary when it isn't the title.
30
+ */
31
+
32
+ // Anything that isn't an object (a string, or a number or nothing read from the audit file) is text.
33
+ /** @param {Text} t */
34
+ const H = t =>
35
+ typeof t !== "object" || t === null
36
+ ? esc(t)
37
+ : Array.isArray(t)
38
+ ? t.map(H).join("")
39
+ : "code" in t
40
+ ? `<code>${esc(t.code)}</code>`
41
+ : "b" in t
42
+ ? `<b>${esc(t.b)}</b>`
43
+ : "id" in t
44
+ ? `<a href="#${esc(t.id)}">${esc(t.id)}</a>`
45
+ : "inl" in t
46
+ ? inl(t.inl)
47
+ : t.html;
48
+ /** @param {Text} t */
49
+ const M = t =>
50
+ typeof t !== "object" || t === null
51
+ ? noteMd(t)
52
+ : Array.isArray(t)
53
+ ? t.map(M).join("")
54
+ : "code" in t
55
+ ? noteCode(t.code)
56
+ : "b" in t
57
+ ? `**${noteMd(t.b)}**`
58
+ : "id" in t
59
+ ? noteMd(t.id)
60
+ : "inl" in t
61
+ ? mdSafe(t.inl)
62
+ : t.md;
63
+ const capped = b => (b.cap ? b.rows.slice(0, b.cap) : b.rows);
64
+
65
+ /** @param {Block} b @returns {string} */
66
+ function blockHtml(b) {
67
+ if (b.mdOnly) return "";
68
+ if ("quiet" in b) return `\n <p class="quiet">${H(b.quiet)}</p>`;
69
+ if ("p" in b || "page" in b) return `<p>${H(b.p ?? b.page)}</p>`;
70
+ if ("head" in b)
71
+ return `<div class="tablewrap"><table><thead><tr>${b.head.map(h => `<th scope="col">${esc(h)}</th>`).join("")}</tr></thead><tbody>${capped(
72
+ b,
73
+ )
74
+ .map(r => `<tr>${r.map(c => `<td>${H(c)}</td>`).join("")}</tr>`)
75
+ .join("")}</tbody></table></div>`;
76
+ if ("rows" in b)
77
+ return b.rows.length
78
+ ? `<ul class="lim">${capped(b)
79
+ .map(([k, v]) => `<li><b>${H(k)}</b>${v === undefined ? "" : `<span>${H(v)}</span>`}</li>`)
80
+ .join("")}</ul>`
81
+ : "";
82
+ if ("sub" in b)
83
+ return `<details><summary>${H(b.sub)}</summary>${b.blocks.filter(Boolean).map(blockHtml).join("")}</details>`;
84
+ if ("panel" in b) return panelHtml(b.panel);
85
+ return b.html ?? "";
86
+ }
87
+ /**
88
+ * @param {Block} b
89
+ * @param {string} level the panel's heading: a list or panel inside it sits one level below
90
+ * @returns {string[]}
91
+ */
92
+ function blockMd(b, level) {
93
+ if ("quiet" in b || "p" in b) return [M(b.quiet ?? b.p), ""];
94
+ if ("head" in b)
95
+ return [
96
+ `| ${b.head.join(" | ")} |`,
97
+ `| ${b.align.join(" | ")} |`,
98
+ ...b.rows.map(r => `| ${r.map(c => cellMd(M(c))).join(" | ")} |`),
99
+ "",
100
+ ];
101
+ if ("rows" in b)
102
+ return b.rows.length
103
+ ? [
104
+ ...b.rows.map(
105
+ ([k, v, sep = " "]) => `- ${b.bold ? `**${M(k)}**` : M(k)}${v === undefined || v === "" ? "" : sep + M(v)}`,
106
+ ),
107
+ "",
108
+ ]
109
+ : [];
110
+ if ("sub" in b)
111
+ return [
112
+ `${level}# ${M(b.heading ?? b.sub)}`,
113
+ "",
114
+ ...b.blocks.filter(Boolean).flatMap(x => blockMd(x, `${level}#`)),
115
+ ];
116
+ if ("panel" in b) return panelMd(b.panel, `${level}#`);
117
+ if ("md" in b) return deeper(b.md, level.length - 2);
118
+ return [];
119
+ }
120
+ /**
121
+ * Markdown written for a ## panel, its headings n levels down (a panel on a topic tab is ###).
122
+ * @param {string[]} lines @param {number} n
123
+ */
124
+ export const deeper = (lines, n) => (n > 0 ? lines.map(l => (/^#{2,5} /.test(l) ? "#".repeat(n) + l : l)) : lines);
125
+
126
+ /** The panel on the page: a collapsed <details>, or its quiet lines as they are. @param {Panel} p */
127
+ export function panelHtml(p) {
128
+ if (!p) return "";
129
+ const body = p.blocks.filter(Boolean).map(blockHtml).join("");
130
+ return p.cls
131
+ ? `\n <details class="how ${p.cls}"><summary>${H(p.summary ?? p.title)}</summary>${body}</details>`
132
+ : body;
133
+ }
134
+ /** The panel in the Markdown: a ## section (### when level is given). @param {Panel} p @param {string} [level] */
135
+ export function panelMd(p, level = "##") {
136
+ return p ? [`${level} ${p.title}`, "", ...p.blocks.filter(Boolean).flatMap(b => blockMd(b, level))] : [];
137
+ }
138
+
139
+ /**
140
+ * Groups panels by tab. Each entry is [tab, card, panel]: a view model function, or a [page, Markdown] pair for one
141
+ * drawn its own way. A view model's own `tab` wins, else "site-content". Panels in one card share a box on the page
142
+ * (null: no box). A panel with nothing to show is left out.
143
+ * @param {[string | null, string | null, (() => any) | [() => string, () => string[]]][]} entries
144
+ * @returns {Record<string, { card: string | null, html: string, md: string[] }[]>}
145
+ */
146
+ export function byTab(entries) {
147
+ const tabs = /** @type {Record<string, { card: string | null, html: string, md: string[] }[]>} */ ({});
148
+ for (const [tab, card, x] of entries) {
149
+ const p = Array.isArray(x) ? null : x() || null,
150
+ [html, md] = Array.isArray(x) ? [x[0](), x[1]()] : [panelHtml(p), panelMd(p, "###")];
151
+ if (html || md.length) (tabs[p?.tab || tab || "site-content"] ||= []).push({ card, html, md });
152
+ }
153
+ return tabs;
154
+ }
155
+ /**
156
+ * One tab's panels on the page: a box per card, in the order the cards first appear.
157
+ * @param {{ card: string | null, html: string }[]} items
158
+ */
159
+ export function cardsHtml(items = []) {
160
+ const cards = new Map();
161
+ items.forEach((x, i) =>
162
+ cards.set(x.card ?? i, { card: x.card, html: (cards.get(x.card ?? i)?.html || "") + x.html }),
163
+ );
164
+ return [...cards.values()]
165
+ .map(c =>
166
+ c.card == null ? c.html : `\n <section class="panel topic"><h2>${esc(c.card)}</h2>${c.html}\n </section>`,
167
+ )
168
+ .join("");
169
+ }
170
+ /** The page's note under a capped list: the Markdown has every row. @param {number} n @param {string | null} mdFile */
171
+ export const listedIn = (n, mdFile) =>
172
+ mdFile && { page: [`All ${num(n)} pages are listed in `, { code: mdFile }, "."] };