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,359 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The panels about the site itself: score views, HSTS preload, coverage, rendering, page scores and check settings.
|
|
3
|
+
import { score, OWN_SCORE } from "../../lib/score.mjs";
|
|
4
|
+
import { cellMd, dot, esc, inl, mdSafe, noteMd, notePath, num, obj, plural, isCount } from "../format.mjs";
|
|
5
|
+
|
|
6
|
+
export function sitePanels({ raw, mdFile, site, areas, overall, open, buildRules, checkSettings }) {
|
|
7
|
+
// The trust view is found ÷ applicable signals × 100 (checks/trust.mjs); missing signals are suggestions, not
|
|
8
|
+
// findings. Local SEO and Content quality are the "Local business" and "Headings & content" area scores renamed, each
|
|
9
|
+
// shown only when its area has checked rules.
|
|
10
|
+
const trustScore = signals => {
|
|
11
|
+
const on = signals.filter(s => s.applies),
|
|
12
|
+
found = on.filter(s => s.found).length;
|
|
13
|
+
return {
|
|
14
|
+
value: on.length ? Math.round((100 * found) / on.length) : null,
|
|
15
|
+
found,
|
|
16
|
+
applicable: on.length,
|
|
17
|
+
missing: on.filter(s => !s.found),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const trustList = Array.isArray(raw.trustSignals) ? raw.trustSignals.filter(obj) : null;
|
|
21
|
+
const NOT_GOOGLE = "SEO Supervisor's own check, not a Google score";
|
|
22
|
+
const labelOf = s => String(s.label || s.id || "");
|
|
23
|
+
function viewsOf() {
|
|
24
|
+
if (!trustList) return null;
|
|
25
|
+
const t = trustScore(trustList),
|
|
26
|
+
list = [
|
|
27
|
+
["Local SEO", "Local business"],
|
|
28
|
+
["Content quality", "Headings & content"],
|
|
29
|
+
]
|
|
30
|
+
.map(([label, name]) => ({ label, a: areas.find(a => a.name === name) }))
|
|
31
|
+
.filter(v => v.a);
|
|
32
|
+
const lc = s => (/^\p{Lu}\p{Ll}/u.test(s) ? s[0].toLowerCase() + s.slice(1) : s);
|
|
33
|
+
const line = `${t.found} of ${t.applicable} signals found${t.missing.length ? ` · missing: ${t.missing.map(s => lc(labelOf(s))).join(", ")}` : ""}`;
|
|
34
|
+
return t.value == null && !list.length ? null : { t, list, line };
|
|
35
|
+
}
|
|
36
|
+
const viewsHtml = () => {
|
|
37
|
+
const v = viewsOf();
|
|
38
|
+
if (!v) return "";
|
|
39
|
+
const pass = `<i class="dot d-pass" aria-hidden="true"></i>`;
|
|
40
|
+
const row = (tag, attrs, d, name, lines, value) => `<li><${tag} class="area"${attrs}>${d}
|
|
41
|
+
<span class="an"><b>${name}</b>${lines}</span>
|
|
42
|
+
<span class="meter" aria-hidden="true"><i style="width:${Math.max(4, value)}%"></i></span><span class="as">${value}<small>/100</small></span></${tag}></li>`;
|
|
43
|
+
const rows = [
|
|
44
|
+
...(v.t.value == null
|
|
45
|
+
? []
|
|
46
|
+
: [
|
|
47
|
+
row(
|
|
48
|
+
"div",
|
|
49
|
+
"",
|
|
50
|
+
v.t.missing.length ? dot("low") : pass,
|
|
51
|
+
"Trust signals (E-E-A-T)",
|
|
52
|
+
`<span class="reason">${esc(v.line)}</span><span class="reason">${esc(NOT_GOOGLE)}</span>`,
|
|
53
|
+
v.t.value,
|
|
54
|
+
),
|
|
55
|
+
]),
|
|
56
|
+
...v.list.map(({ label, a }) =>
|
|
57
|
+
row(
|
|
58
|
+
"a",
|
|
59
|
+
` href="#p-findings" data-area="${esc(a.name)}"`,
|
|
60
|
+
a.worst ? dot(a.worst) : pass,
|
|
61
|
+
esc(label),
|
|
62
|
+
`<span>${esc(a.name)} area · ${a.top.length ? inl(a.top[0].title) : "All checks pass"}</span>`,
|
|
63
|
+
a.value,
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
];
|
|
67
|
+
const add = v.t.missing.length
|
|
68
|
+
? `
|
|
69
|
+
<details class="how"><summary>What to add for trust</summary><p>Suggestions, not findings: they never change the SEO health score, and not every signal fits every site.</p><ul class="lim">${v.t.missing.map(s => `<li><b>${esc(labelOf(s))}</b><span>${inl(s.add || "")}${s.rule ? ` See ${esc(s.rule)}.` : ""}</span></li>`).join("")}</ul></details>`
|
|
70
|
+
: "";
|
|
71
|
+
return `
|
|
72
|
+
<section class="panel factors" aria-labelledby="h-views">
|
|
73
|
+
<div class="ph"><h2 id="h-views">Score views</h2><span class="sub">The audit read another way</span></div>
|
|
74
|
+
<ol class="area-list">${rows.join("")}</ol>${add}
|
|
75
|
+
</section>`;
|
|
76
|
+
};
|
|
77
|
+
const viewsMd = () => {
|
|
78
|
+
const v = viewsOf();
|
|
79
|
+
if (!v) return [];
|
|
80
|
+
const cell = s => cellMd(noteMd(s)); // crawled text: names, links, dates
|
|
81
|
+
const found = trustList.filter(s => s.applies && s.found);
|
|
82
|
+
return [
|
|
83
|
+
"## Score views",
|
|
84
|
+
"",
|
|
85
|
+
"| View | Score | What it is |",
|
|
86
|
+
"| --- | ---: | --- |",
|
|
87
|
+
...(v.t.value == null ? [] : [`| Trust signals (E-E-A-T) | ${v.t.value}/100 | ${cell(v.line)}. ${NOT_GOOGLE} |`]),
|
|
88
|
+
...v.list.map(({ label, a }) => `| ${label} | ${a.value}/100 | The ${cell(a.name)} area's score |`),
|
|
89
|
+
"",
|
|
90
|
+
...(v.t.missing.length
|
|
91
|
+
? [
|
|
92
|
+
"Trust signals to add. They're suggestions, not findings: they never change the score, and not every signal fits every site.",
|
|
93
|
+
"",
|
|
94
|
+
...v.t.missing.map(
|
|
95
|
+
s => `- **${noteMd(labelOf(s))}:** ${mdSafe(s.add || "")}${s.rule ? ` See ${noteMd(s.rule)}.` : ""}`,
|
|
96
|
+
),
|
|
97
|
+
"",
|
|
98
|
+
]
|
|
99
|
+
: []),
|
|
100
|
+
...(found.length
|
|
101
|
+
? [
|
|
102
|
+
"Trust signals found:",
|
|
103
|
+
"",
|
|
104
|
+
...found.map(s => `- **${noteMd(labelOf(s))}:** ${noteMd(s.evidence || "found")}`),
|
|
105
|
+
"",
|
|
106
|
+
]
|
|
107
|
+
: []),
|
|
108
|
+
];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// The home page's HSTS header against the preload list's rules.
|
|
112
|
+
const hstsPreloadText = () => {
|
|
113
|
+
const p = obj(raw.hstsPreload),
|
|
114
|
+
missing = Array.isArray(p?.missing) ? p.missing.filter(s => typeof s === "string") : [];
|
|
115
|
+
if (!p || typeof p.ready !== "boolean") return "";
|
|
116
|
+
const also =
|
|
117
|
+
"hstspreload.org also needs the header on the bare domain, http:// sent to https:// on the same host first, and every subdomain on HTTPS. Joining the list is optional and slow to undo. Information only: it doesn't change the score.";
|
|
118
|
+
return p.ready
|
|
119
|
+
? `HSTS preload: the header meets the list's rules. ${also}`
|
|
120
|
+
: `HSTS preload: not ready yet. The header still needs ${missing.join(" and ")}. ${also}`;
|
|
121
|
+
};
|
|
122
|
+
const hstsPreload = () => hstsPreloadText() && { title: "HSTS preload", blocks: [{ quiet: hstsPreloadText() }] };
|
|
123
|
+
|
|
124
|
+
// Sections show only with two or more; siteSize is set when the crawl stopped at --max. Paths are escaped.
|
|
125
|
+
const siteSections = (Array.isArray(raw.sections) ? raw.sections : [])
|
|
126
|
+
.filter(s => obj(s) && typeof s.path === "string" && isCount(s.pages) && Number.isFinite(s.share))
|
|
127
|
+
.slice(0, 20);
|
|
128
|
+
const coverageLines = () => {
|
|
129
|
+
const z = obj(raw.siteSize),
|
|
130
|
+
i = obj(raw.indexing);
|
|
131
|
+
return [
|
|
132
|
+
z &&
|
|
133
|
+
[z.crawled, z.known, z.sitemapUrls].every(isCount) &&
|
|
134
|
+
`The crawl stopped at ${num(z.crawled)} pages (--max). It knew of ${num(z.known)} URLs on the site from links and sitemaps (the sitemaps list ${num(z.sitemapUrls)}), so the site has at least ${num(Math.max(z.known, z.sitemapUrls))} URLs.`,
|
|
135
|
+
i &&
|
|
136
|
+
[i.indexed, i.notIndexed, i.crawlIndexable].every(isCount) &&
|
|
137
|
+
/^\d{4}-\d{2}-\d{2}$/.test(i.date) &&
|
|
138
|
+
`Search Console counted ${num(i.indexed)} indexed pages (and ${num(i.notIndexed)} not indexed) on ${i.date}; this crawl found ${num(i.crawlIndexable)} pages meant to be indexed${i.capped ? " before it stopped at --max" : ""}. Information only: it doesn't change the score.`,
|
|
139
|
+
].filter(Boolean);
|
|
140
|
+
};
|
|
141
|
+
const SECTIONS_INTRO =
|
|
142
|
+
"How the crawled pages split across the site's top-level folders. Pages with nothing below them count as top-level pages (/). Information only.";
|
|
143
|
+
const pctOf = s => `${Math.round(s * 100)}%`;
|
|
144
|
+
const crawlCoverage = () => {
|
|
145
|
+
const lines = coverageLines(),
|
|
146
|
+
sections = siteSections.length > 1 && {
|
|
147
|
+
cls: "sections",
|
|
148
|
+
title: "Site sections",
|
|
149
|
+
blocks: [
|
|
150
|
+
{ p: SECTIONS_INTRO },
|
|
151
|
+
{
|
|
152
|
+
head: ["Section", "Pages", "Share"],
|
|
153
|
+
align: ["---", "---:", "---:"],
|
|
154
|
+
rows: siteSections.map(s => [{ code: s.path }, num(s.pages), pctOf(s.share)]),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
return (
|
|
159
|
+
(lines.length || sections) && {
|
|
160
|
+
title: "Crawl coverage",
|
|
161
|
+
blocks: [...lines.map(quiet => ({ quiet })), sections && { panel: sections }],
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Findings from these browser loads are listed with the others. Errors, text and addresses come from the site, so
|
|
167
|
+
// each is escaped (code spans in the Markdown).
|
|
168
|
+
const renderPages = (Array.isArray(raw.renderSample) ? raw.renderSample : [])
|
|
169
|
+
.filter(p => obj(p) && typeof p.url === "string")
|
|
170
|
+
.slice(0, 10);
|
|
171
|
+
const chosenPage = (c => (c && typeof c.url === "string" ? c : null))(obj(raw.renderedPage));
|
|
172
|
+
const textsOf = x => (Array.isArray(x) ? x.filter(s => typeof s === "string" && s) : []);
|
|
173
|
+
const firstScreenLine = () => {
|
|
174
|
+
const seen = renderPages.filter(p => !p.gate && obj(p.h1) && obj(p.cta)),
|
|
175
|
+
n = seen.length;
|
|
176
|
+
if (!n) return "";
|
|
177
|
+
const h1 = d => seen.filter(p => p.h1[d] === true).length,
|
|
178
|
+
cta = d => seen.filter(p => typeof p.cta[d] === "string" && p.cta[d]).length;
|
|
179
|
+
return `On a phone, the H1 is on the first screen on ${h1("phone")} of ${plural(n, "page")} and a button on ${cta("phone")} of ${n}; on desktop, ${h1("desktop")} of ${n} and ${cta("desktop")} of ${n}. The first screen and the button are our own measures, not Google rules.`;
|
|
180
|
+
};
|
|
181
|
+
const DEEP_LINK = {
|
|
182
|
+
"scrolled-away": "the page scrolled away from it",
|
|
183
|
+
"hash-removed": "the page removed it from the address",
|
|
184
|
+
both: "the page scrolled away from it and removed it from the address",
|
|
185
|
+
};
|
|
186
|
+
const pageNotes = p => {
|
|
187
|
+
if (typeof p.gate === "string") return [`showed ${p.gate}, so it wasn't compared or measured`];
|
|
188
|
+
const errors = textsOf(p.errors),
|
|
189
|
+
h = obj(p.hidden),
|
|
190
|
+
j = obj(p.jumpLinks),
|
|
191
|
+
broken = textsOf(j?.broken).map(id => `#${id}`);
|
|
192
|
+
return [
|
|
193
|
+
errors.length && `${plural(errors.length, "browser error")}, first: ${errors[0]}`,
|
|
194
|
+
...["phone", "desktop"].map(
|
|
195
|
+
d =>
|
|
196
|
+
obj(p.h1) &&
|
|
197
|
+
p.h1[d] === false &&
|
|
198
|
+
`the H1 isn't on the first screen on ${d === "phone" ? "a phone" : "desktop"}`,
|
|
199
|
+
),
|
|
200
|
+
h &&
|
|
201
|
+
isCount(h.words) &&
|
|
202
|
+
h.words >= 50 &&
|
|
203
|
+
/* our own line */ `${num(h.words)} hidden words (${Object.entries(obj(h.by) || {})
|
|
204
|
+
.filter(([, v]) => isCount(v))
|
|
205
|
+
.map(([k, v]) => `${k} ${num(v)}`)
|
|
206
|
+
.join(", ")})${typeof h.examples?.[0]?.text === "string" ? `, most in “${h.examples[0].text}”` : ""}`,
|
|
207
|
+
broken.length &&
|
|
208
|
+
(broken.length === 1
|
|
209
|
+
? `a link to ${broken[0]}, which isn't on the page`
|
|
210
|
+
: `links to ${broken.join(", ")}, which aren't on the page`),
|
|
211
|
+
DEEP_LINK[j?.deepLink] && typeof j.target === "string" && `opened at #${j.target}, ${DEEP_LINK[j.deepLink]}`,
|
|
212
|
+
p.menu === "no-button" && "no menu button found on a phone",
|
|
213
|
+
p.menu === "covered" && "the phone menu button is covered by another layer",
|
|
214
|
+
].filter(Boolean);
|
|
215
|
+
};
|
|
216
|
+
const renderRows = () => renderPages.map(p => [p.url, pageNotes(p)]).filter(([, b]) => b.length);
|
|
217
|
+
const chosenText = () => {
|
|
218
|
+
const c = chosenPage,
|
|
219
|
+
w = obj(c.words) || {},
|
|
220
|
+
steps = typeof c.steps === "string" && c.steps ? ` and the steps (${c.steps})` : "",
|
|
221
|
+
errors = textsOf(c.errors);
|
|
222
|
+
const changes = (Array.isArray(c.changes) ? c.changes : [])
|
|
223
|
+
.filter(x => obj(x) && typeof x.field === "string")
|
|
224
|
+
.map(x => `${x.field}: ${x.raw ?? "none"} → ${x.rendered ?? "none"}`);
|
|
225
|
+
return `: ${isCount(w.html) ? `${num(w.html)} words in the HTML, ${isCount(w.rendered) ? num(w.rendered) : "?"}` : `${isCount(w.rendered) ? num(w.rendered) : "?"} words`} after JavaScript${steps}. ${changes.length ? `What changed: ${changes.join("; ")}.` : "The title, canonical, robots tag, H1, schema and links match the HTML."}${typeof c.gate === "string" ? ` It showed ${c.gate}.` : ""}${errors.length ? ` ${plural(errors.length, "browser error")}, first: ${errors[0]}.` : ""}`;
|
|
226
|
+
};
|
|
227
|
+
const BROWSER_INTRO =
|
|
228
|
+
"The sample pages loaded again in Chrome at desktop and phone size. Information only; what is a finding is listed with the other findings.";
|
|
229
|
+
const browser = () => {
|
|
230
|
+
const s = firstScreenLine(),
|
|
231
|
+
rows = renderRows();
|
|
232
|
+
return (
|
|
233
|
+
(s || rows.length || chosenPage) && {
|
|
234
|
+
cls: "render",
|
|
235
|
+
title: "What the browser saw",
|
|
236
|
+
blocks: [
|
|
237
|
+
{ p: BROWSER_INTRO },
|
|
238
|
+
s && { p: s },
|
|
239
|
+
{ rows: rows.map(([u, b]) => [{ code: notePath(u) }, b.join(" · ")]) },
|
|
240
|
+
chosenPage && { p: ["You chose ", { code: notePath(chosenPage.url) }, chosenText()] },
|
|
241
|
+
],
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Each page with open findings is scored by the site's model, counting only findings whose examples name it
|
|
247
|
+
// (buildRules' assume). Evidence URLs on other hosts, and files such as sitemaps and robots.txt, are left out.
|
|
248
|
+
const PAGE_INTRO = `Each page with open findings, scored with the same rules as the site but counting only the findings listed for that page. It's ${OWN_SCORE}, and it doesn't change the site score. Pages come from the findings' examples, so a finding with more cases than examples can affect pages not listed here.`;
|
|
249
|
+
const PAGE_FILE = /\.(xml|txt|json|gz|js|css)$/i; // files are told from pages by extension only
|
|
250
|
+
const hostOf = u => {
|
|
251
|
+
try {
|
|
252
|
+
return new URL(u).host.replace(/^www\./, "");
|
|
253
|
+
} catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const pageScores = (() => {
|
|
258
|
+
if (!overall) return [];
|
|
259
|
+
// The site's own pages: its public host and subdomains (staging.), or a local build the crawl ran on (localhost, a
|
|
260
|
+
// LAN address, .local or .test). Pages are keyed by path, as elsewhere in the report. A preview on another domain
|
|
261
|
+
// (a vercel.app link) isn't recognised.
|
|
262
|
+
const home = hostOf(site.url),
|
|
263
|
+
LOCAL =
|
|
264
|
+
/^(localhost|127\.[\d.]+|0\.0\.0\.0|\[::1\]|10\.[\d.]+|192\.168\.[\d.]+|172\.(1[6-9]|2\d|3[01])\.[\d.]+)(:\d+)?$|\.(local|test|localhost)(:\d+)?$/i;
|
|
265
|
+
const own = h => !home || h === home || h.endsWith("." + home) || LOCAL.test(h);
|
|
266
|
+
const pages = new Map();
|
|
267
|
+
for (const f of open)
|
|
268
|
+
for (const e of f.evidence || []) {
|
|
269
|
+
let u;
|
|
270
|
+
try {
|
|
271
|
+
u = new URL(e.url);
|
|
272
|
+
} catch {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (!/^https?:$/.test(u.protocol) || !own(hostOf(u.href)) || PAGE_FILE.test(u.pathname)) continue;
|
|
276
|
+
const p = u.pathname + u.search;
|
|
277
|
+
(pages.get(p) || pages.set(p, new Set()).get(p)).add(f);
|
|
278
|
+
}
|
|
279
|
+
return [...pages]
|
|
280
|
+
.map(([path, fs]) => ({
|
|
281
|
+
path,
|
|
282
|
+
ids: [...fs].map(f => f.id),
|
|
283
|
+
value: score(buildRules({ assume: f => !fs.has(f) })).value,
|
|
284
|
+
}))
|
|
285
|
+
.sort((a, b) => a.value - b.value || b.ids.length - a.ids.length || a.path.localeCompare(b.path));
|
|
286
|
+
})();
|
|
287
|
+
// The page shows the 10 lowest, the Markdown all. PAGE_INTRO is a local sentence, written into the page as is.
|
|
288
|
+
const pageScoresPanel = () =>
|
|
289
|
+
pageScores.length && {
|
|
290
|
+
cls: "pagescores",
|
|
291
|
+
title: "Page scores",
|
|
292
|
+
blocks: [
|
|
293
|
+
{ p: { html: PAGE_INTRO, md: PAGE_INTRO } },
|
|
294
|
+
{
|
|
295
|
+
head: ["Page", "Score", "Open findings"],
|
|
296
|
+
align: ["---", "---:", "---"],
|
|
297
|
+
cap: 10,
|
|
298
|
+
rows: pageScores.map(p => [
|
|
299
|
+
{ code: p.path },
|
|
300
|
+
{ html: String(p.value), md: `${p.value}/100` },
|
|
301
|
+
p.ids.flatMap((id, i) => (i ? [", ", { id }] : [{ id }])),
|
|
302
|
+
]),
|
|
303
|
+
},
|
|
304
|
+
pageScores.length > 10 &&
|
|
305
|
+
mdFile && {
|
|
306
|
+
page: [`The 10 lowest. All ${num(pageScores.length)} pages are listed in `, { code: mdFile }, "."],
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// Every turned-off check, changed severity and warning about settings.json, so a setting is never silent. Ids and
|
|
312
|
+
// warnings come from the user's file, so they're escaped.
|
|
313
|
+
const SETTINGS_INTRO =
|
|
314
|
+
"From seo-audit/settings.json, this project's own settings. A check turned off is left out of the findings, and the score leaves turned-off checks out, as if they hadn't run. A changed severity counts in the score too. Blockers can't be turned off or lowered there.";
|
|
315
|
+
const settingRows = () => [
|
|
316
|
+
...checkSettings.off.map(o => [
|
|
317
|
+
o.check,
|
|
318
|
+
`Turned off: ${o.count ? `${plural(o.count, "finding")} left out` : "no findings this run"}.`,
|
|
319
|
+
]),
|
|
320
|
+
...checkSettings.changed.map(c => [
|
|
321
|
+
c.check,
|
|
322
|
+
`Severity set to ${c.to === "needs-decision" ? "decision needed" : c.to}: ${c.count ? `${plural(c.count, "finding")} changed` : "no findings this run"}.`,
|
|
323
|
+
]),
|
|
324
|
+
];
|
|
325
|
+
const settingsSummary = () =>
|
|
326
|
+
[
|
|
327
|
+
checkSettings.off.length && `${plural(checkSettings.off.length, "check")} turned off`,
|
|
328
|
+
checkSettings.changed.length && `${plural(checkSettings.changed.length, "severity", "severities")} changed`,
|
|
329
|
+
checkSettings.warnings.length && plural(checkSettings.warnings.length, "warning"),
|
|
330
|
+
]
|
|
331
|
+
.filter(Boolean)
|
|
332
|
+
.join(" · ");
|
|
333
|
+
const checkSettingsPanel = () =>
|
|
334
|
+
(settingRows().length || checkSettings.warnings.length) && {
|
|
335
|
+
cls: "checksettings",
|
|
336
|
+
title: "Check settings",
|
|
337
|
+
summary: `Check settings: ${settingsSummary()}`,
|
|
338
|
+
blocks: [
|
|
339
|
+
{ p: SETTINGS_INTRO },
|
|
340
|
+
{
|
|
341
|
+
rows: [
|
|
342
|
+
...settingRows().map(([id, t]) => [{ code: id }, t]),
|
|
343
|
+
...checkSettings.warnings.map(w => ["Warning", w, ": "]),
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
return {
|
|
349
|
+
viewsHtml,
|
|
350
|
+
viewsMd,
|
|
351
|
+
hstsPreload,
|
|
352
|
+
crawlCoverage,
|
|
353
|
+
browser,
|
|
354
|
+
pageScores: pageScoresPanel,
|
|
355
|
+
checkSettings: checkSettingsPanel,
|
|
356
|
+
settingRows,
|
|
357
|
+
settingsSummary,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The speed and image panels, with Lighthouse's details and accessibility checks.
|
|
3
|
+
import { band } from "../../checks/speed.mjs";
|
|
4
|
+
import { esc, fmtDate, inl, noteCode, noteMd, notePath, num, obj, plural } from "../format.mjs";
|
|
5
|
+
import { LCP_PART } from "../overview-lines.mjs";
|
|
6
|
+
import { listedIn } from "../panel.mjs";
|
|
7
|
+
|
|
8
|
+
export function speedPanels({ raw, mdFile, lighthouse }) {
|
|
9
|
+
// Images ranked by what converting or resizing them would save, top 15. Crawled text is escaped.
|
|
10
|
+
const imageRows = (Array.isArray(raw.images) ? raw.images : [])
|
|
11
|
+
.filter(i => obj(i) && typeof i.url === "string" && Number.isFinite(i.bytes) && i.estSaving > 0)
|
|
12
|
+
.sort((a, b) => b.estSaving - a.estSaving)
|
|
13
|
+
.slice(0, 15);
|
|
14
|
+
const kbOf = n => `${num(Math.round(n / 1024))} KB`;
|
|
15
|
+
const imageWhat = i => [i.format, i.width && i.height && `${i.width} × ${i.height} px`].filter(Boolean).join(" · ");
|
|
16
|
+
const IMAGES_INTRO =
|
|
17
|
+
"A rough estimate of what WebP and resizing to 1,600 px wide would save: Google measured lossy WebP 25–34% smaller than JPEG and lossless WebP 26% smaller than PNG, and the low end is used. Information only: it never changes the score. With your yes, scripts/images.mjs converts the JPEG and PNG ones and keeps the originals (it needs the optional image add-on: npx seo-supervisor --with-image-tools).";
|
|
18
|
+
const images = () =>
|
|
19
|
+
imageRows.length && {
|
|
20
|
+
cls: "images",
|
|
21
|
+
title: "Images by possible saving",
|
|
22
|
+
blocks: [
|
|
23
|
+
{ p: IMAGES_INTRO },
|
|
24
|
+
{
|
|
25
|
+
head: ["Image", "Size", "Format", "Possible saving"],
|
|
26
|
+
align: ["---", "---:", "---", "---:"],
|
|
27
|
+
rows: imageRows.map(i => [
|
|
28
|
+
{ code: notePath(i.url) },
|
|
29
|
+
kbOf(i.bytes),
|
|
30
|
+
imageWhat(i),
|
|
31
|
+
`about ${kbOf(i.estSaving)}`,
|
|
32
|
+
]),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Every failed audit except accessibility ones, which the accessibility panel lists, so none shows twice. Titles come
|
|
38
|
+
// from Lighthouse (Markdown backticks included) and files from the site, so both are escaped.
|
|
39
|
+
const isA11y = a => a.category === "Accessibility";
|
|
40
|
+
const lhRuns = lighthouse
|
|
41
|
+
.map(x => ({ path: notePath(x.url), audits: x.detail.filter(a => !isA11y(a)) }))
|
|
42
|
+
.filter(x => x.audits.length);
|
|
43
|
+
const LH_INTRO =
|
|
44
|
+
"Every audit each Lighthouse run failed, with the files or page elements it names (10 at most). The accessibility ones are under Lighthouse's accessibility checks. Information only: Lighthouse's lab results don't change the score.";
|
|
45
|
+
// Lighthouse titles carry `code`: shown as code on the page, escaped in the Markdown.
|
|
46
|
+
const auditTitle = a => ({ html: inl(a.title), md: noteMd(a.title) });
|
|
47
|
+
const codesOf = a => ({
|
|
48
|
+
html: a.items.map(s => `<code>${esc(s)}</code>`).join(", "),
|
|
49
|
+
md: a.items.map(noteCode).join(", "),
|
|
50
|
+
});
|
|
51
|
+
// Each page a list of its own (### in the Markdown); the page shows the first 10 pages, the Markdown all.
|
|
52
|
+
const lighthouseDetail = () =>
|
|
53
|
+
lhRuns.length && {
|
|
54
|
+
cls: "lhdetail",
|
|
55
|
+
title: "Lighthouse details",
|
|
56
|
+
blocks: [
|
|
57
|
+
{ p: LH_INTRO },
|
|
58
|
+
...lhRuns.map((x, i) => ({
|
|
59
|
+
mdOnly: i >= 10,
|
|
60
|
+
sub: [{ code: x.path }, ` · ${plural(x.audits.length, "failed audit")}`],
|
|
61
|
+
heading: { code: x.path },
|
|
62
|
+
blocks: [
|
|
63
|
+
{
|
|
64
|
+
rows: x.audits.map(a => [
|
|
65
|
+
auditTitle(a),
|
|
66
|
+
{
|
|
67
|
+
html: `${esc(a.category || "")}${a.items.length ? ` · ${codesOf(a).html}` : ""}`,
|
|
68
|
+
md: `${a.category ? ` (${noteMd(a.category)})` : ""}${a.items.length ? `: ${codesOf(a).md}` : ""}`,
|
|
69
|
+
},
|
|
70
|
+
"",
|
|
71
|
+
]),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
})),
|
|
75
|
+
lhRuns.length > 10 && listedIn(lhRuns.length, mdFile),
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Speed and image details, in one collapsed panel. Crawled and third-party text (paths, element labels, hosts,
|
|
80
|
+
// versions) is escaped by the two callers.
|
|
81
|
+
const mediaNums = (a, n) => Array.isArray(a) && a.length === n && a.every(Number.isFinite);
|
|
82
|
+
const mediaPair = (k, [a, b]) =>
|
|
83
|
+
k === "cls"
|
|
84
|
+
? `CLS ${a} → ${b}`
|
|
85
|
+
: k === "inp"
|
|
86
|
+
? `INP ${Math.round(a)} → ${Math.round(b)} ms`
|
|
87
|
+
: `LCP ${(a / 1000).toFixed(1)} → ${(b / 1000).toFixed(1)} s`;
|
|
88
|
+
const mediaPairs = (o, keys = ["lcp", "inp", "cls"]) =>
|
|
89
|
+
keys
|
|
90
|
+
.filter(k => mediaNums(o?.[k], 2))
|
|
91
|
+
.map(k => mediaPair(k, o[k]))
|
|
92
|
+
.join(" · ");
|
|
93
|
+
const mediaDay = (s, year = false) => (/^\d{4}-\d{2}-\d{2}$/.test(s) ? fmtDate(s, year) : null);
|
|
94
|
+
const mediaList = (xs, f, max = 5) =>
|
|
95
|
+
xs.slice(0, max).map(f).join(" · ") + (xs.length > max ? ` and ${num(xs.length - max)} more` : "");
|
|
96
|
+
const mediaLines = () => {
|
|
97
|
+
const s = obj(raw.speed),
|
|
98
|
+
m = obj(raw.media) || {},
|
|
99
|
+
L = [],
|
|
100
|
+
arr = x => (Array.isArray(x) ? x.filter(obj) : []),
|
|
101
|
+
str = x => typeof x === "string" && x !== "";
|
|
102
|
+
const samples = arr(s?.samples),
|
|
103
|
+
v = obj(samples.find(x => obj(x.origin))?.origin) || obj(samples.find(x => obj(x.field))?.field);
|
|
104
|
+
const KEYS = ["lcp", "inp", "cls", "fcp", "ttfb"],
|
|
105
|
+
pct = x => `${Math.round(x * 100)}%`;
|
|
106
|
+
const shares = KEYS.filter(k => mediaNums(v?.shares?.[k], 3)).map(
|
|
107
|
+
k => `${k.toUpperCase()} ${v.shares[k].map(pct).join(" / ")}`,
|
|
108
|
+
);
|
|
109
|
+
if (shares.length) L.push(`Share of real visits that were good / needs improvement / poor: ${shares.join(" · ")}.`);
|
|
110
|
+
const other = ["fcp", "ttfb"]
|
|
111
|
+
.filter(k => Number.isFinite(v?.[k]))
|
|
112
|
+
.map(k => `${k.toUpperCase()} ${(v[k] / 1000).toFixed(1)} s (${band(k, v[k])})`);
|
|
113
|
+
if (other.length)
|
|
114
|
+
L.push(
|
|
115
|
+
`Other real-user numbers, not Core Web Vitals: ${other.join(" · ")}. Google's lines: FCP good up to 1.8 s, poor over 3 s; TTFB good up to 0.8 s, poor over 1.8 s, as a rough guide.`,
|
|
116
|
+
);
|
|
117
|
+
const t = obj(s?.trend),
|
|
118
|
+
p = obj(t?.period),
|
|
119
|
+
weeks = Number.isInteger(t?.weeks) ? t.weeks : 0;
|
|
120
|
+
if (p && mediaDay(p.from) && mediaDay(p.to))
|
|
121
|
+
L.push(`Real-user data period: CrUX's latest 28 days, ${mediaDay(p.from)} – ${mediaDay(p.to, true)}.`);
|
|
122
|
+
else if (v && (v.shares || v.fcp != null || v.ttfb != null))
|
|
123
|
+
L.push("Real-user data period: PageSpeed's numbers cover the last 28 days of Chrome visits.");
|
|
124
|
+
const late = mediaPairs(t, ["inp", "cls"]),
|
|
125
|
+
avg = mediaPairs(obj(t?.avg4));
|
|
126
|
+
if (weeks && (late || avg))
|
|
127
|
+
L.push(
|
|
128
|
+
[
|
|
129
|
+
late && `Over ${weeks} weeks (first week → latest): ${late}.`,
|
|
130
|
+
avg && `4-week averages: ${avg} (the first four weeks against the last four).`,
|
|
131
|
+
]
|
|
132
|
+
.filter(Boolean)
|
|
133
|
+
.join(" "),
|
|
134
|
+
);
|
|
135
|
+
const pt = obj(s?.pageTrend),
|
|
136
|
+
ptw = mediaPairs(obj(pt?.trend));
|
|
137
|
+
if (ptw && str(pt.url))
|
|
138
|
+
L.push(
|
|
139
|
+
`${notePath(pt.url) === "/" ? "Home page" : notePath(pt.url)} alone: ${ptw} over ${num(pt.trend.weeks || 0)} weeks.`,
|
|
140
|
+
);
|
|
141
|
+
const tab = obj(s?.tablet),
|
|
142
|
+
tl = obj(tab?.trend)?.lcp,
|
|
143
|
+
tb = obj(tab?.lcpBreakdown);
|
|
144
|
+
if (mediaNums(tl, 2)) {
|
|
145
|
+
const [k] = Object.keys(LCP_PART).sort((x, y) => (tb?.[y] || 0) - (tb?.[x] || 0));
|
|
146
|
+
L.push(
|
|
147
|
+
`Tablet (whole site): ${mediaPair("lcp", tl)} over ${num(tab.trend.weeks || 0)} weeks${tb && Number.isFinite(tb[k]) ? `; most of the LCP goes on ${LCP_PART[k][0]} (${(tb[k] / 1000).toFixed(1)} s)` : ""}.`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const heroes = arr(m.heroImages).filter(h => str(h.url) && str(h.element));
|
|
151
|
+
if (heroes.length)
|
|
152
|
+
L.push(
|
|
153
|
+
`Largest paint in the lab (the LCP element): ${mediaList(heroes, h => `${notePath(h.url)} → ${str(h.src) ? `${h.src} (${h.element})` : h.element}${str(h.source) ? `, ${h.source}` : ""}`)}.`,
|
|
154
|
+
);
|
|
155
|
+
const med = obj(m.lighthouseMedians),
|
|
156
|
+
medParts = [
|
|
157
|
+
["Performance", "performance"],
|
|
158
|
+
["SEO", "seo"],
|
|
159
|
+
["Accessibility", "accessibility"],
|
|
160
|
+
["Best practices", "bestPractices"],
|
|
161
|
+
]
|
|
162
|
+
.filter(([, k]) => Number.isFinite(med?.[k]))
|
|
163
|
+
.map(([n, k]) => `${n} ${med[k]}`);
|
|
164
|
+
if (medParts.length && Number.isInteger(med.pages))
|
|
165
|
+
L.push(`Lighthouse medians across ${num(med.pages)} pages: ${medParts.join(" · ")}.`);
|
|
166
|
+
const runs = lighthouse.filter(x => Number.isInteger(x.passed)),
|
|
167
|
+
ver = runs.find(x => str(x.version))?.version;
|
|
168
|
+
if (runs.length)
|
|
169
|
+
L.push(
|
|
170
|
+
`Lighthouse${ver ? ` ${ver}` : ""}: ${mediaList(runs, x => `${notePath(x.url)} passed ${num(x.passed)} audits, failed ${num(x.detail.length)}`)}.`,
|
|
171
|
+
);
|
|
172
|
+
const psiVer = samples.map(x => obj(x.lab)?.version).find(str);
|
|
173
|
+
if (psiVer) L.push(`PageSpeed's lab runs used Lighthouse ${psiVer}.`);
|
|
174
|
+
const st = obj(m.serverTimes),
|
|
175
|
+
slow = arr(st?.slow).filter(x => str(x.url) && Number.isFinite(x.ms));
|
|
176
|
+
if (st && [st.pages, st.median, st.p95].every(Number.isFinite))
|
|
177
|
+
L.push(
|
|
178
|
+
`Server response time, one request per page from this machine, ${num(st.pages)} pages: median ${num(st.median)} ms, the slowest 5% from ${num(st.p95)} ms.${slow.length ? ` Over 0.8 s (web.dev's “good” time to first byte for real visitors): ${mediaList(slow, x => `${notePath(x.url)} ${(x.ms / 1000).toFixed(1)} s`)}.` : ""}`,
|
|
179
|
+
);
|
|
180
|
+
const ds = obj(m.domShape),
|
|
181
|
+
deep = arr(ds?.deep).filter(d => str(d.url) && Number.isFinite(d.depth)),
|
|
182
|
+
wide = arr(ds?.wide).filter(d => str(d.url) && str(d.tag) && Number.isFinite(d.children));
|
|
183
|
+
if (deep.length)
|
|
184
|
+
L.push(
|
|
185
|
+
`Nested more than 32 levels deep (our own line, from older Lighthouse advice): ${mediaList(deep, d => `${notePath(d.url)} ${d.depth} levels`)}. Deep nesting usually means wrapper elements that could go.`,
|
|
186
|
+
);
|
|
187
|
+
if (wide.length)
|
|
188
|
+
L.push(
|
|
189
|
+
`An element with more than 60 children (our own line): ${mediaList(wide, d => `${notePath(d.url)} ${d.tag} (${num(d.children)})`)}. Long lists can load in parts.`,
|
|
190
|
+
);
|
|
191
|
+
const cr = obj(m.imageCredits);
|
|
192
|
+
if (cr && Number.isInteger(cr.read) && cr.read > 0) {
|
|
193
|
+
const ai = (Array.isArray(cr.ai) ? cr.ai : []).filter(str),
|
|
194
|
+
aiN = Number.isInteger(cr.aiCount) ? cr.aiCount : ai.length,
|
|
195
|
+
none = (Array.isArray(cr.noCreator) ? cr.noCreator : []).filter(str);
|
|
196
|
+
L.push(
|
|
197
|
+
`Image credits, read from ${plural(cr.read, "image")}: ${num(cr.creator || 0)} name a creator, ${num(aiN)} ${aiN === 1 ? "is" : "are"} labelled as made with AI${ai.length ? ` (${mediaList(ai, notePath)})` : ""}, ${num(cr.c2pa || 0)} carry Content Credentials (C2PA).${none.length ? ` No creator: ${mediaList(none, notePath)}.` : ""}`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
const ca = obj(m.imageCache),
|
|
201
|
+
unc = (Array.isArray(ca?.uncached) ? ca.uncached : []).filter(str),
|
|
202
|
+
hosts = Object.entries(obj(ca?.otherHosts) || {}).filter(([h, n]) => str(h) && Number.isInteger(n));
|
|
203
|
+
const uncN = Number.isInteger(ca?.uncachedCount) ? ca.uncachedCount : unc.length;
|
|
204
|
+
if (ca && ((Number.isInteger(ca.checked) && ca.checked > 0) || hosts.length))
|
|
205
|
+
L.push(
|
|
206
|
+
[
|
|
207
|
+
ca.checked > 0 &&
|
|
208
|
+
(uncN
|
|
209
|
+
? `Image caching: ${num(uncN)} of ${plural(ca.checked, "image")} are sent with no cache lifetime${unc.length ? ` (${mediaList(unc, notePath)})` : ""}, so browsers download them again on every visit.`
|
|
210
|
+
: `Image caching: ${ca.checked === 1 ? "the 1 image checked is" : `all ${num(ca.checked)} images checked are`} sent with a cache lifetime.`),
|
|
211
|
+
str(ca.cdn) && `They come through ${ca.cdn}.`,
|
|
212
|
+
hosts.length && `Images on other hosts: ${mediaList(hosts, ([h, n]) => `${h} (${num(n)})`)}.`,
|
|
213
|
+
]
|
|
214
|
+
.filter(Boolean)
|
|
215
|
+
.join(" "),
|
|
216
|
+
);
|
|
217
|
+
return L;
|
|
218
|
+
};
|
|
219
|
+
const MEDIA_INTRO = "Information only: none of this changes the score.";
|
|
220
|
+
const speedDetails = () => {
|
|
221
|
+
const L = mediaLines();
|
|
222
|
+
return (
|
|
223
|
+
L.length && { cls: "media", title: "Speed and image details", blocks: [MEDIA_INTRO, ...L].map(p => ({ p })) }
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// lighthouse.mjs keeps each failed audit with its category title, "Accessibility" in the English runs it starts.
|
|
228
|
+
// Accessibility audits are pass or fail, and some checks, such as trapped focus, need a manual review.
|
|
229
|
+
// https://developer.chrome.com/docs/lighthouse/accessibility/scoring
|
|
230
|
+
const a11yRuns = lighthouse
|
|
231
|
+
.map(x => ({
|
|
232
|
+
path: notePath(x.url),
|
|
233
|
+
score: Number.isInteger(x.scores?.accessibility) ? x.scores.accessibility : null,
|
|
234
|
+
audits: x.detail.filter(isA11y),
|
|
235
|
+
}))
|
|
236
|
+
.filter(x => x.audits.length);
|
|
237
|
+
const A11Y_INTRO =
|
|
238
|
+
"Lighthouse's own accessibility checks that failed on each page it ran, with the page elements it names (10 at most). Each check is pass or fail. They're Lighthouse's checks, not SEO Supervisor's, and they can't find everything: some problems, such as keyboard focus that gets trapped, only a person can check. Information only: they don't change the score.";
|
|
239
|
+
const a11yHead = x =>
|
|
240
|
+
`${x.score != null ? `Accessibility ${x.score} · ` : ""}${plural(x.audits.length, "failed check")}`;
|
|
241
|
+
// The summary is written into the page as is ("Lighthouse's").
|
|
242
|
+
const a11y = () =>
|
|
243
|
+
a11yRuns.length && {
|
|
244
|
+
cls: "a11y",
|
|
245
|
+
title: "Lighthouse's accessibility checks",
|
|
246
|
+
summary: { html: `Lighthouse's accessibility checks · ${plural(a11yRuns.length, "page")} with failed checks` },
|
|
247
|
+
blocks: [
|
|
248
|
+
{ p: A11Y_INTRO },
|
|
249
|
+
...a11yRuns.map((x, i) => ({
|
|
250
|
+
mdOnly: i >= 10,
|
|
251
|
+
sub: [{ code: x.path }, ` · ${a11yHead(x)}`],
|
|
252
|
+
heading: [{ code: x.path }, ` (${a11yHead(x)})`],
|
|
253
|
+
blocks: [
|
|
254
|
+
{
|
|
255
|
+
rows: x.audits.map(a => [
|
|
256
|
+
auditTitle(a),
|
|
257
|
+
{ html: codesOf(a).html, md: a.items.length ? `: ${codesOf(a).md}` : "" },
|
|
258
|
+
"",
|
|
259
|
+
]),
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
})),
|
|
263
|
+
a11yRuns.length > 10 && listedIn(a11yRuns.length, mdFile),
|
|
264
|
+
],
|
|
265
|
+
};
|
|
266
|
+
return { images, lighthouseDetail, speedDetails, a11y };
|
|
267
|
+
}
|