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.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- 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 +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- 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 +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- 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 +515 -158
- 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/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 +324 -690
- 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 +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- 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 +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The Links tab's panels: backlinks, outbound links, internal link ideas and link strength.
|
|
3
|
+
import { fmtDate, notePath, num, obj, plural, isCount, isText } from "../format.mjs";
|
|
4
|
+
import { byPath } from "../traffic.mjs";
|
|
5
|
+
|
|
6
|
+
const linkCount = p => plural(Number(p.count) || 0, "link");
|
|
7
|
+
|
|
8
|
+
export function linkPanels({ raw }) {
|
|
9
|
+
const bing = obj(raw.bing),
|
|
10
|
+
traffic = obj(raw.traffic);
|
|
11
|
+
// Bing's pages with links from other sites; linked also feeds the Bing search line.
|
|
12
|
+
const linked = Array.isArray(bing?.backlinks?.pages) ? bing.backlinks.pages.filter(obj) : [];
|
|
13
|
+
const topLinked = [...linked].sort((a, b) => (Number(b.count) || 0) - (Number(a.count) || 0)).slice(0, 10);
|
|
14
|
+
const linkSample = (Array.isArray(bing?.backlinks?.sample) ? bing.backlinks.sample.filter(obj) : []).slice(0, 5);
|
|
15
|
+
const bingLinks = topLinked.length || linkSample.length;
|
|
16
|
+
// backlinks.mjs: whether known links from other sites are still there. Third-party URLs, escaped where shown.
|
|
17
|
+
const linkCheck = obj(raw.backlinks),
|
|
18
|
+
checkedLinks = Number(linkCheck?.checked) || 0;
|
|
19
|
+
const goneLinks = Array.isArray(linkCheck?.gone) ? linkCheck.gone.filter(obj) : [];
|
|
20
|
+
const linkCheckLine = checkedLinks
|
|
21
|
+
? `${num(Number(linkCheck.live) || 0)} of ${num(checkedLinks)} known ${checkedLinks === 1 ? "link is" : "links are"} still there; ${num(goneLinks.length)} gone; ${num(Array.isArray(linkCheck.unreachable) ? linkCheck.unreachable.filter(obj).length : 0)} couldn't be checked`
|
|
22
|
+
: "";
|
|
23
|
+
// Search Console's exports, the backlink check and Bing's lists share one collapsed panel. Domains, URLs and counts
|
|
24
|
+
// come from other sites, so they're escaped where shown.
|
|
25
|
+
const scLinks = obj(raw.links),
|
|
26
|
+
scRows = (k, f) =>
|
|
27
|
+
Array.isArray(scLinks?.[k]) ? scLinks[k].filter(x => obj(x) && typeof x[f] === "string" && x[f]) : [];
|
|
28
|
+
const scSites = scRows("sites", "domain"),
|
|
29
|
+
scPages = scRows("pages", "url");
|
|
30
|
+
const scMix = (m =>
|
|
31
|
+
m && ["brand", "address", "generic", "other"].every(k => Number.isFinite(m[k]) && m[k] >= 0 && m[k] <= 1)
|
|
32
|
+
? m
|
|
33
|
+
: null)(obj(raw.anchorMix));
|
|
34
|
+
const hasSc = !!(scSites.length || scPages.length || scMix),
|
|
35
|
+
linkSources = [hasSc && "Search Console", bingLinks && "Bing"].filter(Boolean).join(" and ");
|
|
36
|
+
// Search Console's tables export at most 1,000 rows, so 1,000 may be more.
|
|
37
|
+
// https://support.google.com/webmasters/answer/9049606
|
|
38
|
+
const scUpTo = n => (n >= 1000 ? "1,000 or more" : num(n));
|
|
39
|
+
const scLine = () => {
|
|
40
|
+
const parts = [
|
|
41
|
+
scSites.length && `${scUpTo(scSites.length)} site${scSites.length === 1 ? " links" : "s link"} to you`,
|
|
42
|
+
scPages.length && `${scUpTo(scPages.length)} of your pages ${scPages.length === 1 ? "has" : "have"} links`,
|
|
43
|
+
].filter(Boolean);
|
|
44
|
+
return parts.length
|
|
45
|
+
? `Search Console${Date.parse(scLinks.when) ? ` (export of ${fmtDate(scLinks.when)})` : ""}: ${parts.join(" · ")}`
|
|
46
|
+
: "";
|
|
47
|
+
};
|
|
48
|
+
const scPct = x => `${Math.round(x * 100)}%`;
|
|
49
|
+
const scMixLine = () =>
|
|
50
|
+
`Link text: your brand ${scPct(scMix.brand)} · web address ${scPct(scMix.address)} · generic, like “click here”, ${scPct(scMix.generic)} · other ${scPct(scMix.other)}.`;
|
|
51
|
+
const scInfoLine = () =>
|
|
52
|
+
`${scMix ? "A natural mix is mostly your brand, your web address and words that say what the page is about. " : ""}Information only: it doesn't change the score.`;
|
|
53
|
+
const scCount = x => (Number.isFinite(x.links) ? plural(x.links, "link") : "");
|
|
54
|
+
const scList = (list, f) => ({ rows: list.slice(0, 5).map(x => [{ code: x[f] }, scCount(x)]) });
|
|
55
|
+
// worthALook (links-import.mjs): standout links, each with why and what to look at.
|
|
56
|
+
const looks = (Array.isArray(raw.worthALook) ? raw.worthALook : [])
|
|
57
|
+
.filter(x => obj(x) && ["subject", "why", "look"].every(k => typeof x[k] === "string" && x[k]))
|
|
58
|
+
.slice(0, 10);
|
|
59
|
+
const lookEx = x => (Array.isArray(x.examples) ? x.examples.filter(e => typeof e === "string" && e).slice(0, 5) : []);
|
|
60
|
+
const LOOK_INTRO = "Worth a look: links that stand out. It isn't a score or a finding, and most turn out to be fine.";
|
|
61
|
+
// Other sites' addresses as code, their text escaped. "Bing's" in a label is written into the page as it is.
|
|
62
|
+
const label = s => ({ p: { html: s, md: s } });
|
|
63
|
+
const links = () =>
|
|
64
|
+
(hasSc || bingLinks || linkCheckLine || looks.length) && {
|
|
65
|
+
cls: "links",
|
|
66
|
+
title: `Links from other sites${linkSources ? ` (${linkSources})` : ""}`,
|
|
67
|
+
blocks: [
|
|
68
|
+
scLine() && { p: scLine() },
|
|
69
|
+
scSites.length && { p: "The sites with the most links to you:" },
|
|
70
|
+
scSites.length && scList(scSites, "domain"),
|
|
71
|
+
scPages.length && { p: "Your most-linked pages in Search Console:" },
|
|
72
|
+
scPages.length && scList(scPages, "url"),
|
|
73
|
+
scMix && { p: scMixLine() },
|
|
74
|
+
hasSc && { p: scInfoLine() },
|
|
75
|
+
looks.length && { p: LOOK_INTRO },
|
|
76
|
+
{
|
|
77
|
+
bold: true,
|
|
78
|
+
rows: looks.map(x => [
|
|
79
|
+
x.subject,
|
|
80
|
+
[
|
|
81
|
+
x.why,
|
|
82
|
+
" ",
|
|
83
|
+
x.look,
|
|
84
|
+
lookEx(x).length ? [" For example: ", lookEx(x).map((e, i) => [i ? ", " : "", { code: e }])] : "",
|
|
85
|
+
],
|
|
86
|
+
": ",
|
|
87
|
+
]),
|
|
88
|
+
},
|
|
89
|
+
linkCheckLine && { p: linkCheckLine },
|
|
90
|
+
linkCheckLine && { rows: goneLinks.slice(0, 10).map(g => [{ code: g.url }, g.reason ?? ""]) },
|
|
91
|
+
topLinked.length && {
|
|
92
|
+
p: hasSc ? "Your most-linked pages in Bing:" : "The pages with the most links from other sites:",
|
|
93
|
+
},
|
|
94
|
+
{ rows: topLinked.map(p => [{ code: p.url }, linkCount(p)]) },
|
|
95
|
+
linkSample.length &&
|
|
96
|
+
label(hasSc ? "Some of Bing's links to the home page:" : "Some of the links to the home page:"),
|
|
97
|
+
{ rows: linkSample.map(s => [{ code: s.url }, s.anchorText || ""]) },
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// More about links, in one collapsed panel. Names, addresses and link text come from other sites, so each is escaped
|
|
102
|
+
// (code spans in the Markdown).
|
|
103
|
+
const listOf = (x, ok) => (Array.isArray(x) ? x.filter(ok) : []);
|
|
104
|
+
const isDay = x => typeof x === "string" && /^\d{4}-\d{2}-\d{2}$/.test(x) && !isNaN(Date.parse(x));
|
|
105
|
+
const newSites = (n =>
|
|
106
|
+
n && isCount(n.count) && n.count > 0
|
|
107
|
+
? { ...n, sites: listOf(n.sites, s => obj(s) && isText(s.domain)).slice(0, 5) }
|
|
108
|
+
: null)(obj(raw.newLinks));
|
|
109
|
+
const noNewLinks = (n => (n && isDay(n.newest) && isDay(n.asOf) ? n : null))(obj(raw.noNewLinks));
|
|
110
|
+
const unlinked = (u =>
|
|
111
|
+
u && isCount(u.count) && u.count > 0 && isCount(u.of) && u.of >= u.count
|
|
112
|
+
? { ...u, urls: listOf(u.urls, isText).slice(0, 5) }
|
|
113
|
+
: null)(obj(raw.unlinkedPages));
|
|
114
|
+
const nofollowSites = listOf(linkCheck?.nofollowSites, s => obj(s) && isText(s.site) && isCount(s.pages)).slice(
|
|
115
|
+
0,
|
|
116
|
+
10,
|
|
117
|
+
);
|
|
118
|
+
const foundLinks = listOf(linkCheck?.found, f => obj(f) && isText(f.url) && Array.isArray(f.links))
|
|
119
|
+
.flatMap(f =>
|
|
120
|
+
listOf(f.links, l => obj(l) && isText(l.href))
|
|
121
|
+
.slice(0, 1)
|
|
122
|
+
.map(l => ({ url: f.url, ...l })),
|
|
123
|
+
)
|
|
124
|
+
.slice(0, 10);
|
|
125
|
+
const commonCrawl = (c =>
|
|
126
|
+
c && isText(obj(c.crawl)?.name)
|
|
127
|
+
? {
|
|
128
|
+
name: c.crawl.name,
|
|
129
|
+
site: obj(c.site) && isCount(c.site.captures) ? c.site : null,
|
|
130
|
+
pages: listOf(c.linkingPages, p => obj(p) && isText(p.url) && isText(p.state)),
|
|
131
|
+
sites: listOf(c.linkingSites, isText),
|
|
132
|
+
}
|
|
133
|
+
: null)(obj(raw.commonCrawl));
|
|
134
|
+
// commoncrawl.mjs --rank: the domain's place in Common Crawl's web graph by harmonic centrality, or how far down it
|
|
135
|
+
// isn't.
|
|
136
|
+
const ccRank = (r =>
|
|
137
|
+
r &&
|
|
138
|
+
isText(r.domain) &&
|
|
139
|
+
isText(r.release) &&
|
|
140
|
+
isCount(r.domains) &&
|
|
141
|
+
(r.found === true ? isCount(r.harmonicPos) : r.found === false && isCount(r.scanned))
|
|
142
|
+
? r
|
|
143
|
+
: null)(obj(obj(raw.commonCrawl)?.rank));
|
|
144
|
+
const outLinks = (o =>
|
|
145
|
+
o && obj(o.pages) && Object.keys(o.pages).length
|
|
146
|
+
? {
|
|
147
|
+
pages: Object.values(o.pages).filter(isCount),
|
|
148
|
+
domains: Object.entries(obj(o.domains) || {}).filter(([k, v]) => isText(k) && isCount(v)),
|
|
149
|
+
}
|
|
150
|
+
: null)(obj(raw.linksToOtherSites));
|
|
151
|
+
const bingSample = Array.isArray(bing?.backlinks?.sample) ? bing.backlinks.sample.filter(obj).length : 0;
|
|
152
|
+
const moreLinkLines = () => {
|
|
153
|
+
const L = []; // [text, list of [name, detail]]
|
|
154
|
+
if (newSites)
|
|
155
|
+
L.push([
|
|
156
|
+
`${plural(newSites.count, "new site")} ${newSites.count === 1 ? "links" : "link"} to you since the last export${Date.parse(newSites.since) ? ` (${fmtDate(newSites.since)})` : ""}, from Search Console's Top linking sites.${newSites.capped === true ? " Some may be older links: an export holds 1,000 sites at most, so they may have been past the cut before." : ""}`,
|
|
157
|
+
newSites.sites.map(s => [s.domain, isCount(s.links) ? plural(s.links, "link") : ""]),
|
|
158
|
+
]);
|
|
159
|
+
if (noNewLinks)
|
|
160
|
+
L.push([
|
|
161
|
+
`No new links for 3 months or more: no link in Search Console's Latest links export was found after ${fmtDate(noNewLinks.newest)} (export of ${fmtDate(noNewLinks.asOf)}). New links usually come from new things worth linking to, like original data, a free tool, a guide or real news (LINK-10).`,
|
|
162
|
+
[],
|
|
163
|
+
]);
|
|
164
|
+
if (unlinked)
|
|
165
|
+
L.push([
|
|
166
|
+
`${num(unlinked.count)} of your ${num(unlinked.of)} crawled pages have no links from other sites in Search Console's list. That's normal for most pages. For the ones that matter most, link to them from your pages that other sites do link to.`,
|
|
167
|
+
unlinked.urls.map(u => [notePath(u), ""]),
|
|
168
|
+
]);
|
|
169
|
+
if (nofollowSites.length)
|
|
170
|
+
L.push([
|
|
171
|
+
"Sites whose links to you are all nofollow, sponsored or ugc, in the backlink check. Such links are allowed; Google says links marked this way “will generally not be followed”.",
|
|
172
|
+
nofollowSites.map(s => [s.site, plural(s.pages, "page")]),
|
|
173
|
+
]);
|
|
174
|
+
if (foundLinks.length)
|
|
175
|
+
L.push([
|
|
176
|
+
"Links the backlink check found, with the page each points at and its text:",
|
|
177
|
+
foundLinks.map(f => [
|
|
178
|
+
f.url,
|
|
179
|
+
`→ ${f.href}${isText(f.text) ? ` “${f.text}”` : ""}${isText(f.rel) ? ` (${f.rel})` : ""}`,
|
|
180
|
+
]),
|
|
181
|
+
]);
|
|
182
|
+
if (commonCrawl) {
|
|
183
|
+
const s = commonCrawl.site,
|
|
184
|
+
linked = commonCrawl.pages.filter(p => p.state === "links").length,
|
|
185
|
+
absent = commonCrawl.pages.filter(p => p.state === "not-in-crawl").length;
|
|
186
|
+
if (s)
|
|
187
|
+
L.push([
|
|
188
|
+
s.captures
|
|
189
|
+
? `Common Crawl (${commonCrawl.name}) holds ${s.capped === true ? "1,000 or more" : num(s.captures)} saved copies of your site's pages${s.home === true ? ", the home page among them" : ", but not the home page"}.`
|
|
190
|
+
: `Common Crawl (${commonCrawl.name}) holds none of your site's pages. If robots.txt blocks CCBot, its crawler, that's why.`,
|
|
191
|
+
[],
|
|
192
|
+
]);
|
|
193
|
+
if (commonCrawl.pages.length)
|
|
194
|
+
L.push([
|
|
195
|
+
`${num(linked)} of ${num(commonCrawl.pages.length)} known linking pages link to you in Common Crawl's saved copies${absent ? `; ${num(absent)} ${absent === 1 ? "isn't" : "aren't"} in its newest crawl` : ""}. commoncrawl.mjs --rank adds your domain's rank in its web graph.`,
|
|
196
|
+
commonCrawl.sites.slice(0, 5).map(h => [h, ""]),
|
|
197
|
+
]);
|
|
198
|
+
}
|
|
199
|
+
if (ccRank)
|
|
200
|
+
L.push([
|
|
201
|
+
`Common Crawl's web graph (${ccRank.release}): ${ccRank.found ? `${ccRank.domain} is #${num(ccRank.harmonicPos)} of ${num(ccRank.domains)} domains by how well linked it is (harmonic centrality)${isCount(ccRank.pageRankPos) ? `, #${num(ccRank.pageRankPos)} by PageRank` : ""}` : `${ccRank.domain} isn't in the top ${num(ccRank.scanned)} of ${num(ccRank.domains)} domains${ccRank.capped ? " (the read stopped there)" : ""}`}. Common Crawl's own number, not Google's, and information only.`,
|
|
202
|
+
[],
|
|
203
|
+
]);
|
|
204
|
+
// How much of the link profile the free sources cover.
|
|
205
|
+
// https://support.google.com/webmasters/answer/9049606
|
|
206
|
+
const cover = [
|
|
207
|
+
hasSc &&
|
|
208
|
+
`Google says Search Console's Links report “isn't a comprehensive list of every link on your site”, and each of its tables stops at 1,000 rows${scSites.length >= 1000 ? " (Top linking sites reached it)" : ""}.`,
|
|
209
|
+
bingSample && `Bing's links here are a sample of ${plural(bingSample, "link")} to your home page.`,
|
|
210
|
+
checkedLinks && `The backlink check opened ${plural(checkedLinks, "known linking page")} (100 at most).`,
|
|
211
|
+
commonCrawl && "Common Crawl holds only the pages its monthly crawl reached.",
|
|
212
|
+
].filter(Boolean);
|
|
213
|
+
if (cover.length)
|
|
214
|
+
L.push([`How much this covers: ${cover.join(" ")} Treat the numbers as a sample, not a full count.`, []]);
|
|
215
|
+
return L;
|
|
216
|
+
};
|
|
217
|
+
const MORE_LINKS_INTRO = "Information only: none of this changes the score.";
|
|
218
|
+
const moreLinks = () => {
|
|
219
|
+
const L = moreLinkLines();
|
|
220
|
+
return (
|
|
221
|
+
L.length && {
|
|
222
|
+
cls: "morelinks",
|
|
223
|
+
title: "More about links",
|
|
224
|
+
blocks: [
|
|
225
|
+
{ p: MORE_LINKS_INTRO },
|
|
226
|
+
...L.flatMap(([t, list]) => [{ p: t }, { rows: list.map(([k, v]) => [{ code: k }, v]) }]),
|
|
227
|
+
],
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
// The site's own outbound links get their own card, apart from the links in; domains escaped.
|
|
232
|
+
const outLinksPanel = () => {
|
|
233
|
+
if (!outLinks) return null;
|
|
234
|
+
const n = outLinks.pages.filter(c => c > 0).length,
|
|
235
|
+
top = [...outLinks.domains].sort((a, b) => b[1] - a[1]).slice(0, 5);
|
|
236
|
+
const all = outLinks.domains.length,
|
|
237
|
+
shown = all > top.length ? `; the top ${top.length} are below` : "";
|
|
238
|
+
return {
|
|
239
|
+
cls: "outlinks",
|
|
240
|
+
title: "Links to other sites",
|
|
241
|
+
blocks: [
|
|
242
|
+
{
|
|
243
|
+
p: `${num(n)} of your ${num(outLinks.pages.length)} crawled pages ${n === 1 ? "links" : "link"} to other sites, ${plural(all, "site")} in all${shown}. Pages that make claims should link to their sources (CONTENT-10). ${MORE_LINKS_INTRO}`,
|
|
244
|
+
},
|
|
245
|
+
{ rows: top.map(([d, c]) => [{ code: d }, plural(c, "address", "addresses")]) },
|
|
246
|
+
],
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// linkIdeas and queryGaps (keyword-ideas.mjs), copied into the audit as they are. Searches and paths are escaped. Up
|
|
251
|
+
// to 10 of each on the page, all of them (50 at most) in the Markdown.
|
|
252
|
+
const ideaRows = (key, list) =>
|
|
253
|
+
(Array.isArray(raw[key]) ? raw[key] : []).filter(
|
|
254
|
+
i =>
|
|
255
|
+
obj(i) &&
|
|
256
|
+
typeof i.page === "string" &&
|
|
257
|
+
typeof i.query === "string" &&
|
|
258
|
+
Number.isFinite(i.impressions) &&
|
|
259
|
+
Array.isArray(i[list]) &&
|
|
260
|
+
i[list].length &&
|
|
261
|
+
i[list].every(s => typeof s === "string"),
|
|
262
|
+
);
|
|
263
|
+
// Google uses links for relevance and to find pages; the query-gap idea is from Chen and Koudas, a preprint.
|
|
264
|
+
// https://developers.google.com/search/docs/crawling-indexing/links-crawlable
|
|
265
|
+
// https://arxiv.org/abs/2610.15033
|
|
266
|
+
const ideaPanel = (cls, title, intro, rows) =>
|
|
267
|
+
rows.length && {
|
|
268
|
+
cls,
|
|
269
|
+
title,
|
|
270
|
+
blocks: [
|
|
271
|
+
{ p: intro },
|
|
272
|
+
{ rows, cap: 10 },
|
|
273
|
+
rows.length > 10 && {
|
|
274
|
+
page: [`${num(rows.length - 10)} more in `, { code: "seo-audit/keyword-ideas.md" }, "."],
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
const linkIdeas = () =>
|
|
279
|
+
ideaPanel(
|
|
280
|
+
"linkideas",
|
|
281
|
+
"Internal link ideas",
|
|
282
|
+
"Pages that mention a search another page shows for in Google, but don't link to that page. A link from them, in a sentence about the search, helps people and Google find the page that answers it. From Search Console and the crawl. Information only: none of this changes the score.",
|
|
283
|
+
ideaRows("linkIdeas", "from").map(i => [
|
|
284
|
+
{ code: i.page },
|
|
285
|
+
[
|
|
286
|
+
`gets ${plural(i.impressions, "impression")} for “${i.query}”. Pages that mention it but don't link to it: `,
|
|
287
|
+
i.from.map((p, n) => [n ? ", " : "", { code: p }]),
|
|
288
|
+
],
|
|
289
|
+
]),
|
|
290
|
+
);
|
|
291
|
+
const queryGaps = () =>
|
|
292
|
+
ideaPanel(
|
|
293
|
+
"querygaps",
|
|
294
|
+
"Searches a page doesn't mention",
|
|
295
|
+
"Searches a page shows for in Google whose words its title, H1 and main text don't use. A page can't answer a search well if it never mentions it, and a 2026 study of AI answers (Chen and Koudas, a preprint, not yet peer reviewed) found that pages whose title and paragraphs match the questions people ask get cited more. Add the words only where they fit the page. Information only: none of this changes the score.",
|
|
296
|
+
ideaRows("queryGaps", "missing").map(i => [
|
|
297
|
+
{ code: i.page },
|
|
298
|
+
`shows for “${i.query}” (${plural(i.impressions, "impression")}), but doesn't use: ${i.missing.join(", ")}.`,
|
|
299
|
+
]),
|
|
300
|
+
);
|
|
301
|
+
// Indexable pages with exactly one internal link in: the first 20, capped when the crawl stopped at --max. Paths are
|
|
302
|
+
// escaped.
|
|
303
|
+
const linkedOnce = (o =>
|
|
304
|
+
o && isCount(o.count) && Array.isArray(o.pages)
|
|
305
|
+
? {
|
|
306
|
+
...o,
|
|
307
|
+
pages: o.pages.filter(p => obj(p) && typeof p.url === "string" && typeof p.from === "string").slice(0, 20),
|
|
308
|
+
}
|
|
309
|
+
: null)(obj(raw.linkedOnce));
|
|
310
|
+
const linkedOnceIntro = () =>
|
|
311
|
+
`${plural(linkedOnce.count, "page")} that can be indexed ${linkedOnce.count === 1 ? "has" : "have"} only one other page linking to ${linkedOnce.count === 1 ? "it" : "them"}${linkedOnce.count > linkedOnce.pages.length ? `; the first ${num(linkedOnce.pages.length)} are below` : ""}. A page linked from one place is easy to miss: visitors find it only if they open that one page, and crawlers, which find pages by following links, have a single way in, so the page is cut off if that link goes. A link from a hub or a related page helps both.${linkedOnce.capped === true ? " The crawl stopped at --max, so links on pages it didn't read aren't counted." : ""} Information only: it doesn't change the score.`;
|
|
312
|
+
const linkedOncePanel = () =>
|
|
313
|
+
linkedOnce?.pages.length && {
|
|
314
|
+
cls: "linkedonce",
|
|
315
|
+
title: "Pages with one incoming link",
|
|
316
|
+
blocks: [
|
|
317
|
+
{ p: linkedOnceIntro() },
|
|
318
|
+
{
|
|
319
|
+
rows: linkedOnce.pages.map(p => [
|
|
320
|
+
{ code: notePath(p.url) },
|
|
321
|
+
["linked only from ", { code: notePath(p.from) }],
|
|
322
|
+
]),
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
};
|
|
326
|
+
// linkStrength is a local measure, 0–100: PageRank over the site's own links (sources in checks/link-strength.mjs).
|
|
327
|
+
// With Search Console traffic it also lists, of the 20 crawled pages with the most clicks, those in the bottom third
|
|
328
|
+
// of strength, a local rule. Paths are escaped.
|
|
329
|
+
const n0 = x => Number(x) || 0;
|
|
330
|
+
const strength = (s => {
|
|
331
|
+
const pages =
|
|
332
|
+
s && obj(s.pages)
|
|
333
|
+
? Object.entries(s.pages)
|
|
334
|
+
.filter(([, v]) => Number.isInteger(v) && v >= 0 && v <= 100)
|
|
335
|
+
.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
|
|
336
|
+
: [];
|
|
337
|
+
if (!pages.length) return null;
|
|
338
|
+
const asc = pages.map(([, v]) => v).reverse(),
|
|
339
|
+
cut = asc[Math.ceil(asc.length / 3) - 1],
|
|
340
|
+
top = pages[0][1];
|
|
341
|
+
const weak = traffic
|
|
342
|
+
? pages
|
|
343
|
+
.map(([u, v]) => ({ u, v, t: byPath(traffic, u) }))
|
|
344
|
+
.filter(x => x.t && (n0(x.t.clicks) || n0(x.t.impressions)))
|
|
345
|
+
.sort((a, b) => n0(b.t.clicks) - n0(a.t.clicks) || n0(b.t.impressions) - n0(a.t.impressions))
|
|
346
|
+
.slice(0, 20)
|
|
347
|
+
.filter(x => x.v <= cut && x.v < top)
|
|
348
|
+
: [];
|
|
349
|
+
return { pages, median: isCount(s.median) ? s.median : null, capped: s.capped === true, weak };
|
|
350
|
+
})(obj(raw.linkStrength));
|
|
351
|
+
const LS_LABEL =
|
|
352
|
+
"This is our own measure, computed with the PageRank formula (Brin and Page, 1998) on this site's own links. It's not Google's PageRank, which uses links from the whole web and isn't public.";
|
|
353
|
+
const strengthIntro = () =>
|
|
354
|
+
`How much of the site's own linking reaches each page, from 0 to 100. ${LS_LABEL} A page gets more when more pages link to it, and more again when those pages are strong. 100 is the site's strongest page, and 0 means no more than a page nothing links to. The scale is logarithmic: the home page and a few others usually hold most of the strength, and on a straight scale nearly every other page would read close to 0. Here, twice the share of links is always the same number of extra points. It's relative to the ${plural(strength.pages.length, "page")} this crawl read that can be indexed${strength.median != null ? `; half of them have a strength of ${strength.median} or less` : ""}.${strength.capped ? " The crawl stopped at --max, so links on pages it didn't read aren't counted." : ""} Information only: it doesn't change the score.`;
|
|
355
|
+
const weakIntro = () =>
|
|
356
|
+
`Found in search, but little link strength: of the 20 crawled pages with the most Search Console clicks, then impressions${raw.trafficPeriod ? ` (${String(raw.trafficPeriod).toLowerCase()})` : ""}, these are in the bottom third of the site's strength (our own rule). People already find them in search, so they're worth more links from your own pages. Link to them from the strongest pages above, in a sentence about what they cover, and see Internal link ideas for pages that already mention their searches.`;
|
|
357
|
+
const weakTail = x =>
|
|
358
|
+
`strength ${x.v} · Search Console: ${num(n0(x.t.clicks))} clicks · ${num(n0(x.t.impressions))} impressions`;
|
|
359
|
+
const linkStrength = () =>
|
|
360
|
+
strength && {
|
|
361
|
+
cls: "linkstrength",
|
|
362
|
+
title: "Internal link strength",
|
|
363
|
+
blocks: [
|
|
364
|
+
{ p: strengthIntro() },
|
|
365
|
+
{ rows: strength.pages.slice(0, 10).map(([u, v]) => [{ code: u }, `strength ${v}`]) },
|
|
366
|
+
strength.weak.length && { p: weakIntro() },
|
|
367
|
+
{ rows: strength.weak.map(x => [{ code: x.u }, weakTail(x)]) },
|
|
368
|
+
],
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
linked,
|
|
372
|
+
links,
|
|
373
|
+
moreLinks,
|
|
374
|
+
outLinks: outLinksPanel,
|
|
375
|
+
linkIdeas,
|
|
376
|
+
queryGaps,
|
|
377
|
+
linkedOnce: linkedOncePanel,
|
|
378
|
+
linkStrength,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The local panels on the Site & content tab: the local business and the local rank grid.
|
|
3
|
+
import { esc, fmtDate, noteMd, num, obj, plural } from "../format.mjs";
|
|
4
|
+
import { isA } from "../../lib/business.mjs";
|
|
5
|
+
|
|
6
|
+
export function localPanels({ raw }) {
|
|
7
|
+
// OpenStreetMap's credit goes wherever its data shows (ODbL). Names, addresses and evidence come from the site or
|
|
8
|
+
// from OpenStreetMap, so each is escaped.
|
|
9
|
+
// https://osmfoundation.org/wiki/Licence/Attribution_Guidelines
|
|
10
|
+
const lbRaw = obj(raw.localBusiness),
|
|
11
|
+
nbRaw = obj(raw.nearby),
|
|
12
|
+
gcRaw = obj(raw.geocode);
|
|
13
|
+
const LOCAL_KIND = {
|
|
14
|
+
storefront: "Customers come to the business's address: a storefront.",
|
|
15
|
+
"service-area":
|
|
16
|
+
"The business goes to its customers: a service-area business. It may hide its street address, so the address check doesn't ask for it (LOCAL-06).",
|
|
17
|
+
hybrid:
|
|
18
|
+
"Customers come to the business's address, and it also goes to them. Keep the address on the site and in the schema, and list the towns it serves as areaServed (LOCAL-12).",
|
|
19
|
+
};
|
|
20
|
+
// A trade that goes to its customers (HomeAndConstructionBusiness types in data/business-types.json) isn't told they
|
|
21
|
+
// come to its address when the site shows one: Google says a business that doesn't serve customers there should hide
|
|
22
|
+
// it.
|
|
23
|
+
// https://support.google.com/business/answer/3038177
|
|
24
|
+
const trade =
|
|
25
|
+
lbRaw &&
|
|
26
|
+
typeof lbRaw.type === "string" &&
|
|
27
|
+
lbRaw.kind !== "service-area" &&
|
|
28
|
+
LOCAL_KIND[lbRaw.kind] &&
|
|
29
|
+
isA(lbRaw.type, "HomeAndConstructionBusiness");
|
|
30
|
+
const TRADE = t =>
|
|
31
|
+
`A business like this (schema.org files ${t} under home and construction) usually goes to its customers, and its schema gives a street address. If customers come to that address too, keep it on the site and in the schema, and list the towns it serves as areaServed (LOCAL-12). If they don't, Google asks a business to hide an address where it doesn't serve customers (LOCAL-06).`;
|
|
32
|
+
const OSM_CREDIT =
|
|
33
|
+
"Map data © OpenStreetMap contributors, under the Open Database License (https://www.openstreetmap.org/copyright).";
|
|
34
|
+
const lcFin = x => typeof x === "number" && Number.isFinite(x);
|
|
35
|
+
const lcDist = m => (m < 1000 ? `${num(Math.round(m))} m` : `${+(m / 1000).toFixed(1)} km`);
|
|
36
|
+
const lcStr = x => typeof x === "string" && x.trim() !== "";
|
|
37
|
+
// [text, list of [name, detail]] blocks, and whether OpenStreetMap's data is shown.
|
|
38
|
+
const localLines = () => {
|
|
39
|
+
const L = [];
|
|
40
|
+
if (lbRaw && LOCAL_KIND[lbRaw.kind])
|
|
41
|
+
L.push([
|
|
42
|
+
trade ? TRADE(lbRaw.type) : LOCAL_KIND[lbRaw.kind],
|
|
43
|
+
(Array.isArray(lbRaw.evidence) ? lbRaw.evidence.filter(lcStr) : []).slice(0, 6).map(e => [e, ""]),
|
|
44
|
+
]);
|
|
45
|
+
const nb = nbRaw && [nbRaw.count, nbRaw.radiusM, nbRaw.perKm2].every(lcFin) ? nbRaw : null;
|
|
46
|
+
if (nb)
|
|
47
|
+
L.push([
|
|
48
|
+
`OpenStreetMap lists ${plural(nb.count, "other place")} of the same kind (${lcStr(nb.label) ? nb.label : "the business's type"}) within ${lcDist(nb.radiusM)} of ${lcStr(nb.centerFrom) ? nb.centerFrom : "the business"}: about ${nb.perKm2} per km². Context only: volunteers keep OpenStreetMap, so it can miss businesses or list closed ones.`,
|
|
49
|
+
(Array.isArray(nb.places) ? nb.places : [])
|
|
50
|
+
.filter(p => obj(p) && lcStr(p.name) && lcFin(p.distanceM))
|
|
51
|
+
.slice(0, 10)
|
|
52
|
+
.map(p => [p.name, lcDist(p.distanceM)]),
|
|
53
|
+
]);
|
|
54
|
+
const g = gcRaw && lcStr(gcRaw.query) ? gcRaw : null,
|
|
55
|
+
f = obj(g?.found);
|
|
56
|
+
if (g && !f)
|
|
57
|
+
L.push([
|
|
58
|
+
`OpenStreetMap's Nominatim couldn't find “${g.query}”. If the address is right, it may just be missing from OpenStreetMap; that's not a problem with the site.`,
|
|
59
|
+
[],
|
|
60
|
+
]);
|
|
61
|
+
else if (g && lcFin(f.lat) && lcFin(f.lon)) {
|
|
62
|
+
if (lcFin(g.distanceM))
|
|
63
|
+
L.push([
|
|
64
|
+
g.distanceM > 250
|
|
65
|
+
? `OpenStreetMap's Nominatim places “${g.query}” ${lcDist(g.distanceM)} from the schema's geo. Check which is right on a map: geo should mark the business's own door (LOCAL-06).`
|
|
66
|
+
: `OpenStreetMap's Nominatim places “${g.query}” ${lcDist(g.distanceM)} from the schema's geo, so the two agree.`,
|
|
67
|
+
[],
|
|
68
|
+
]);
|
|
69
|
+
else if (g.suggestGeo === true)
|
|
70
|
+
L.push([
|
|
71
|
+
`The schema has no geo. OpenStreetMap's Nominatim places “${g.query}” at ${f.lat.toFixed(5)}, ${f.lon.toFixed(5)}. Check the point on a map, then add it to the business schema as geo, with latitude and longitude (LOCAL-06).`,
|
|
72
|
+
[],
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
return { L, osm: !!nb || !!g };
|
|
76
|
+
};
|
|
77
|
+
const LOCAL_INTRO = "Information only: none of this changes the score. 250 m is our own line for the address check.";
|
|
78
|
+
const local = () => {
|
|
79
|
+
const { L, osm } = localLines();
|
|
80
|
+
return (
|
|
81
|
+
L.length && {
|
|
82
|
+
cls: "local",
|
|
83
|
+
title: "Local business",
|
|
84
|
+
blocks: [
|
|
85
|
+
{ p: LOCAL_INTRO },
|
|
86
|
+
...L.flatMap(([t, list]) => [{ p: t }, { rows: list.map(([k, v]) => [k, v || undefined]) }]),
|
|
87
|
+
osm && {
|
|
88
|
+
html: `<p class="quiet">Map data <a href="https://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, under the Open Database License.</p>`,
|
|
89
|
+
md: [noteMd(OSM_CREDIT), ""],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// geoGrid comes from geo-grid.json. Google's terms forbid Places results on a non-Google map, so it's a plain grid
|
|
97
|
+
// with north at the top, credited "Google Maps". Counts come from the cells, never the file's own totals, and the
|
|
98
|
+
// label is written here, not read from the file.
|
|
99
|
+
// https://cloud.google.com/maps-platform/terms/maps-service-terms
|
|
100
|
+
const GRID_SIZES = new Set([5, 7, 9]);
|
|
101
|
+
const grid = (g => {
|
|
102
|
+
if (!g || !GRID_SIZES.has(g.size) || !Array.isArray(g.keywords)) return null;
|
|
103
|
+
const n = g.size,
|
|
104
|
+
inGrid = c => obj(c) && [c.row, c.col].every(v => Number.isInteger(v) && v >= 0 && v < n);
|
|
105
|
+
const rankOf = r => (Number.isInteger(r) && r >= 1 && r <= 20 ? r : r === "error" ? "error" : null);
|
|
106
|
+
const keywords = g.keywords
|
|
107
|
+
.filter(k => obj(k) && typeof k.keyword === "string" && k.keyword.trim() && Array.isArray(k.cells))
|
|
108
|
+
.slice(0, 3)
|
|
109
|
+
.map(k => {
|
|
110
|
+
const at = Array.from({ length: n }, () => Array(n).fill(undefined));
|
|
111
|
+
for (const c of k.cells.filter(inGrid)) at[c.row][c.col] = rankOf(c.rank);
|
|
112
|
+
const seen = at.flat().filter(v => v !== undefined),
|
|
113
|
+
count = f => seen.filter(f).length,
|
|
114
|
+
ranked = r => typeof r === "number";
|
|
115
|
+
return {
|
|
116
|
+
keyword: k.keyword.trim(),
|
|
117
|
+
at,
|
|
118
|
+
points: seen.length,
|
|
119
|
+
top3: count(r => ranked(r) && r <= 3),
|
|
120
|
+
top10: count(r => ranked(r) && r <= 10),
|
|
121
|
+
notFound: count(r => r === null),
|
|
122
|
+
failed: count(r => r === "error"),
|
|
123
|
+
};
|
|
124
|
+
})
|
|
125
|
+
.filter(k => k.points === n * n); // a grid with holes would mislead, so it isn't drawn
|
|
126
|
+
if (!keywords.length) return null;
|
|
127
|
+
// The run's own notes, including any third-party credit Google returned, which its terms require showing.
|
|
128
|
+
const notes = (Array.isArray(g.notes) ? g.notes : [])
|
|
129
|
+
.filter(t => typeof t === "string" && t.trim())
|
|
130
|
+
.slice(0, 6)
|
|
131
|
+
.map(t => t.trim().slice(0, 400));
|
|
132
|
+
return {
|
|
133
|
+
n,
|
|
134
|
+
keywords,
|
|
135
|
+
notes,
|
|
136
|
+
km: Number.isFinite(g.spacingKm) && g.spacingKm > 0 && g.spacingKm <= 50 ? g.spacingKm : null,
|
|
137
|
+
date: /^\d{4}-\d{2}-\d{2}$/.test(g.date) ? g.date : null,
|
|
138
|
+
};
|
|
139
|
+
})(obj(raw.geoGrid));
|
|
140
|
+
const GRID_BANDS = [
|
|
141
|
+
["top3", "1–3"],
|
|
142
|
+
["top10", "4–10"],
|
|
143
|
+
["top20", "11–20"],
|
|
144
|
+
["out", "Not in the top 20"],
|
|
145
|
+
["err", "Not checked"],
|
|
146
|
+
];
|
|
147
|
+
const gridBand = r => (r === "error" ? "err" : r === null ? "out" : r <= 3 ? "top3" : r <= 10 ? "top10" : "top20");
|
|
148
|
+
const gridIntro = () =>
|
|
149
|
+
`Where your business appears in the list Google's Places API returns near each spot: an approximation of Google Maps results, not a copy. Each square is a spot${grid.km ? ` ${+grid.km.toFixed(2)} km` : ""} apart around your business, north at the top, and the outlined square is your business.${grid.date ? ` Checked on ${fmtDate(grid.date)}.` : ""} Information only: it doesn't change the score.`;
|
|
150
|
+
const gridLine = k =>
|
|
151
|
+
`Top 3 at ${k.top3} of ${k.points} spots · top 10 at ${k.top10} · not in the top 20 at ${k.notFound}${k.failed ? ` · ${k.failed} not checked` : ""}`;
|
|
152
|
+
// Where a square is, from the business: "2 km north, 1 km west".
|
|
153
|
+
const gridWhere = (row, col) => {
|
|
154
|
+
const c = (grid.n - 1) / 2,
|
|
155
|
+
away = (d, plus, minus) =>
|
|
156
|
+
d &&
|
|
157
|
+
`${grid.km ? `${+(Math.abs(d) * grid.km).toFixed(2)} km` : plural(Math.abs(d), "square")} ${d > 0 ? plus : minus}`;
|
|
158
|
+
return row === c && col === c
|
|
159
|
+
? "Your business"
|
|
160
|
+
: [away(row - c, "south", "north"), away(col - c, "east", "west")].filter(Boolean).join(", ");
|
|
161
|
+
};
|
|
162
|
+
const gridSay = r =>
|
|
163
|
+
r === "error" ? "not checked, the request failed" : r === null ? "not in the top 20" : `position ${r}`;
|
|
164
|
+
const geoGridHtml = () =>
|
|
165
|
+
grid
|
|
166
|
+
? `\n <details class="how geogrid"><summary>Local rank grid</summary><p>${esc(gridIntro())}</p>` +
|
|
167
|
+
`<p class="gg-legend">${GRID_BANDS.filter(([b]) => b !== "err" || grid.keywords.some(k => k.failed))
|
|
168
|
+
.map(([b, t]) => `<span><i class="gg-${b}" aria-hidden="true"></i>${esc(t)}</span>`)
|
|
169
|
+
.join("")}</p><div class="gg-list">` +
|
|
170
|
+
grid.keywords
|
|
171
|
+
.map(
|
|
172
|
+
k =>
|
|
173
|
+
`<figure class="gg"><figcaption><b>${esc(k.keyword)}</b><span>${esc(gridLine(k))}</span></figcaption><span class="gg-north" aria-hidden="true">North</span>` +
|
|
174
|
+
`<div class="gg-grid" style="--n:${grid.n}" role="img" aria-label="${esc(`${k.keyword}: ${gridLine(k).replace(/^Top/, "top")}`)}">` +
|
|
175
|
+
k.at
|
|
176
|
+
.map((row, i) =>
|
|
177
|
+
row
|
|
178
|
+
.map(
|
|
179
|
+
(r, j) =>
|
|
180
|
+
`<span class="gg-c gg-${gridBand(r)}${i === (grid.n - 1) / 2 && j === i ? " gg-centre" : ""}" title="${esc(`${gridWhere(i, j)}: ${gridSay(r)}`)}">${r === "error" ? "–" : r === null ? "20+" : r}</span>`,
|
|
181
|
+
)
|
|
182
|
+
.join(""),
|
|
183
|
+
)
|
|
184
|
+
.join("") +
|
|
185
|
+
`</div><p class="gg-credit">Places data: Google Maps</p></figure>`,
|
|
186
|
+
)
|
|
187
|
+
.join("") +
|
|
188
|
+
`</div>${grid.notes.map(t => `<p>${esc(t)}</p>`).join("")}</details>`
|
|
189
|
+
: "";
|
|
190
|
+
const geoGridMd = () =>
|
|
191
|
+
grid
|
|
192
|
+
? [
|
|
193
|
+
"## Local rank grid",
|
|
194
|
+
"",
|
|
195
|
+
noteMd(gridIntro()),
|
|
196
|
+
"",
|
|
197
|
+
...grid.keywords.flatMap(k => [
|
|
198
|
+
`### ${noteMd(k.keyword)}`,
|
|
199
|
+
"",
|
|
200
|
+
noteMd(gridLine(k)),
|
|
201
|
+
"",
|
|
202
|
+
"```",
|
|
203
|
+
"North",
|
|
204
|
+
...k.at.map((row, i) =>
|
|
205
|
+
row
|
|
206
|
+
.map((r, j) => {
|
|
207
|
+
const t = r === "error" ? "-" : r === null ? "20+" : String(r);
|
|
208
|
+
return (i === (grid.n - 1) / 2 && j === i ? `[${t}]` : t).padStart(3);
|
|
209
|
+
})
|
|
210
|
+
.join(" "),
|
|
211
|
+
),
|
|
212
|
+
"```",
|
|
213
|
+
"",
|
|
214
|
+
]),
|
|
215
|
+
"Places data: Google Maps",
|
|
216
|
+
"",
|
|
217
|
+
...grid.notes.flatMap(t => [noteMd(t), ""]),
|
|
218
|
+
]
|
|
219
|
+
: [];
|
|
220
|
+
return { local, geoGridHtml, geoGridMd };
|
|
221
|
+
}
|