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,421 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// E-E-A-T signals for the report's trust view, read from the crawled HTML. They're never findings or scored: Google
|
|
3
|
+
// says E-E-A-T isn't a ranking factor, so the view is a local check, not a Google score.
|
|
4
|
+
// https://developers.google.com/search/docs/fundamentals/creating-helpful-content
|
|
5
|
+
// HTML is read with regexes; page names and paths are matched in English and a few European languages.
|
|
6
|
+
import { isBusinessType } from "../lib/business.mjs";
|
|
7
|
+
import { attrs, jsonLdNodes, textOf } from "../lib/html.mjs";
|
|
8
|
+
|
|
9
|
+
// a is the attribute text after the tag name.
|
|
10
|
+
const attr = (a, name) => attrs("<a " + a + ">")[name] ?? null;
|
|
11
|
+
const words = s =>
|
|
12
|
+
s
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(/[^\p{L}\p{N}\s'-]+/gu, " ")
|
|
15
|
+
.replace(/\s+/g, " ")
|
|
16
|
+
.trim();
|
|
17
|
+
const bare = h => (h || "").toLowerCase().replace(/^www\./, "");
|
|
18
|
+
const hostOf = u => {
|
|
19
|
+
try {
|
|
20
|
+
return bare(new URL(u).hostname);
|
|
21
|
+
} catch {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const pathOf = u => {
|
|
26
|
+
try {
|
|
27
|
+
const x = new URL(u);
|
|
28
|
+
return x.pathname + x.search;
|
|
29
|
+
} catch {
|
|
30
|
+
return u;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const uniq = (list, n = 3) => [...new Set(list.filter(Boolean))].slice(0, n);
|
|
34
|
+
const typesOf = n => [].concat(n["@type"] || []).filter(t => typeof t === "string");
|
|
35
|
+
const deepHas = (o, pred, depth = 0) =>
|
|
36
|
+
!!o && typeof o === "object" && depth < 12 && (pred(o) || Object.values(o).some(v => deepHas(v, pred, depth + 1)));
|
|
37
|
+
|
|
38
|
+
// Google's Article markup takes Article, NewsArticle and BlogPosting; their subtypes end the same way.
|
|
39
|
+
// https://developers.google.com/search/docs/appearance/structured-data/article
|
|
40
|
+
const ARTICLE = /(Article|BlogPosting)$/;
|
|
41
|
+
const SHOP = /^(Product|ProductGroup|Offer|AggregateOffer)$/;
|
|
42
|
+
|
|
43
|
+
// Path segments (file extension dropped) and link texts that name each kind of page.
|
|
44
|
+
const ABOUT_SEG =
|
|
45
|
+
/^(about|about-us|about-me|who-we-are|our-story|our-team|team|meet-the-team|company|ueber-uns|uber-uns|a-propos|qui-sommes-nous|sobre|sobre-nosotros|quienes-somos|chi-siamo|over-ons|om-oss)$/;
|
|
46
|
+
const ABOUT_TXT =
|
|
47
|
+
/^(about|about us|about me|who we are|our story|our team|meet the team|the team|über uns|a propos|à propos|qui sommes-nous|sobre nosotros|quiénes somos|chi siamo|over ons|om oss)$/;
|
|
48
|
+
const CONTACT_SEG =
|
|
49
|
+
/^(contact|contact-us|contacts|get-in-touch|kontakt|contacto|contato|contatti|nous-contacter|contactez-nous)$/;
|
|
50
|
+
const CONTACT_TXT =
|
|
51
|
+
/^(contact|contact us|get in touch|kontakt|contacto|contáctenos|contatti|nous contacter|contactez-nous)$/;
|
|
52
|
+
const POLICY = {
|
|
53
|
+
privacy: [
|
|
54
|
+
/privacy|datenschutz|privacidad|privacidade|confidentialite|riservatezza/,
|
|
55
|
+
/privacy|datenschutz|privacidad|confidentialité/,
|
|
56
|
+
],
|
|
57
|
+
terms: [
|
|
58
|
+
/terms|conditions|condiciones|nutzungsbedingungen|terminos|^(tos|agb|cgv|cgu)$/,
|
|
59
|
+
/\bterms\b|conditions|\bagb\b|términos|condiciones|\bcgv\b|\bcgu\b/,
|
|
60
|
+
],
|
|
61
|
+
returns: [
|
|
62
|
+
/^([\w-]+-)?(returns?|refunds?|retours?|widerruf[\w-]*|devoluciones)(-[\w-]+)?$/,
|
|
63
|
+
/\b(returns|refunds|refund policy|return policy|retours|widerruf\w*|devoluciones)\b/,
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
const PROOF_SEG =
|
|
67
|
+
/^(testimonials?|reviews|case-stud(y|ies)|customer-stor(y|ies)|success-stor(y|ies)|customers|clients)$/;
|
|
68
|
+
const PROOF_TXT =
|
|
69
|
+
/\b(testimonials?|reviews|customer reviews?|case stud(y|ies)|customer stor(y|ies)|success stor(y|ies)|what (our )?(clients|customers) (say|think))\b/;
|
|
70
|
+
const REVIEW_WIDGET =
|
|
71
|
+
/<(?:script|iframe)\b[^>]*\ssrc\s*=\s*["']?[^"'\s>]*(trustpilot\.com|yotpo\.com|judge\.me|reviews\.io|feefo\.com|okendo\.io|stamped\.io|bazaarvoice\.com)/i;
|
|
72
|
+
const AUTHOR_PATH = /(^|\/)(author|authors|team|people|staff|contributors?|writers?)\/[^/]+/;
|
|
73
|
+
const MONTH =
|
|
74
|
+
"January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sept?|Oct|Nov|Dec";
|
|
75
|
+
const DATE_TXT = new RegExp(
|
|
76
|
+
`\\b(\\d{1,2}(st|nd|rd|th)?\\s+(of\\s+)?(${MONTH})\\.?,?\\s+\\d{4}|(${MONTH})\\.?\\s+\\d{1,2}(st|nd|rd|th)?,?\\s+\\d{4})\\b|\\b\\d{4}-\\d{2}-\\d{2}\\b`,
|
|
77
|
+
);
|
|
78
|
+
// Links that share or follow rather than cite, and images that aren't the site's own.
|
|
79
|
+
const SOCIAL =
|
|
80
|
+
/(^|\.)(facebook\.com|twitter\.com|x\.com|linkedin\.com|instagram\.com|pinterest\.[a-z.]+|tiktok\.com|whatsapp\.com|wa\.me|t\.me|threads\.net|bsky\.app|reddit\.com|youtube\.com|youtu\.be)$/;
|
|
81
|
+
// Only stock photos hot-linked from these hosts are spotted; downloaded and self-hosted ones can't be.
|
|
82
|
+
const STOCK =
|
|
83
|
+
/(^|\.)(unsplash\.com|pexels\.com|pixabay\.com|istockphoto\.com|shutterstock\.com|gettyimages\.[a-z.]+|stock\.adobe\.com|ftcdn\.net|depositphotos\.com|dreamstime\.com|123rf\.com|placehold\.co|placeholder\.com|picsum\.photos|gravatar\.com)$/i;
|
|
84
|
+
// content-scan.mjs's unsourced-stat pattern, read on the page's main text.
|
|
85
|
+
const STAT =
|
|
86
|
+
/\b\d{1,3}(?:\.\d+)?\s?%\s+of\b|\b(?:studies|research|surveys?)\s+(?:show|shows|suggests?|proves?|found|finds|has shown|have shown)\b/i;
|
|
87
|
+
const CITED = /https?:\/\/|\[\d+\]|\bsource:|\baccording to\b/i;
|
|
88
|
+
|
|
89
|
+
// One page's evidence for each signal. The crawler passes what it already parsed: the JSON-LD nodes, the HTML from
|
|
90
|
+
// <body> on, and resolve(href), which returns a URL against base, or null.
|
|
91
|
+
export function trustFeatures(
|
|
92
|
+
html,
|
|
93
|
+
url,
|
|
94
|
+
base = url,
|
|
95
|
+
{
|
|
96
|
+
nodes = jsonLdNodes(html).nodes,
|
|
97
|
+
bodyRaw = (i => (i >= 0 ? html.slice(i) : html))(html.search(/<body\b/i)),
|
|
98
|
+
resolve = h => {
|
|
99
|
+
try {
|
|
100
|
+
return new URL(h, base);
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
} = {},
|
|
106
|
+
) {
|
|
107
|
+
const types = nodes.flatMap(typesOf);
|
|
108
|
+
const body = bodyRaw.replace(/<(script|style|template)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi, " ");
|
|
109
|
+
const main =
|
|
110
|
+
body.match(/<main\b[^>]*>([\s\S]*?)<\/main>/i)?.[1] ??
|
|
111
|
+
body.replace(/<(header|nav|footer|aside)\b[\s\S]*?<\/\1>/gi, " ");
|
|
112
|
+
// Each href is resolved once, however many kinds of page ask about it.
|
|
113
|
+
const read = new Map(),
|
|
114
|
+
at = h => {
|
|
115
|
+
let r = read.get(h);
|
|
116
|
+
if (!r) {
|
|
117
|
+
let u = resolve(h);
|
|
118
|
+
if (u && !/^https?:$/.test(u.protocol)) u = null;
|
|
119
|
+
read.set(
|
|
120
|
+
h,
|
|
121
|
+
(r = {
|
|
122
|
+
u,
|
|
123
|
+
segs: (u?.pathname.toLowerCase() || "")
|
|
124
|
+
.split("/")
|
|
125
|
+
.filter(Boolean)
|
|
126
|
+
.map(s => s.replace(/\.(html?|php|aspx?)$/, "")),
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return r;
|
|
131
|
+
};
|
|
132
|
+
const abs = h => at(h).u,
|
|
133
|
+
segsOf = h => at(h).segs,
|
|
134
|
+
own = hostOf(url);
|
|
135
|
+
const linksIn = h =>
|
|
136
|
+
[...h.matchAll(/<a\b([^>]*)>([\s\S]*?)<\/a>/gi)].map(m => ({
|
|
137
|
+
a: m[1],
|
|
138
|
+
href: attr(m[1], "href") || "",
|
|
139
|
+
text: words(textOf(m[2])),
|
|
140
|
+
}));
|
|
141
|
+
const links = linksIn(body),
|
|
142
|
+
self = segsOf(url),
|
|
143
|
+
selfPath = pathOf(url);
|
|
144
|
+
// Links anywhere on the page (menu, body or footer) to a page of this kind, plus the page itself when it is one.
|
|
145
|
+
const to = (seg, txt) =>
|
|
146
|
+
uniq([
|
|
147
|
+
...(self.some(s => seg.test(s)) ? [selfPath] : []),
|
|
148
|
+
...links.filter(l => abs(l.href) && (segsOf(l.href).some(s => seg.test(s)) || txt.test(l.text))).map(l => l.href),
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
const article = types.some(t => ARTICLE.test(t)),
|
|
152
|
+
shop = types.some(t => SHOP.test(t));
|
|
153
|
+
const byId = id => nodes.find(n => n["@id"] === id);
|
|
154
|
+
const authors = nodes
|
|
155
|
+
.filter(n => typesOf(n).some(t => ARTICLE.test(t)))
|
|
156
|
+
.flatMap(n => [].concat(n.author || []))
|
|
157
|
+
.map(a =>
|
|
158
|
+
typeof a === "string"
|
|
159
|
+
? { name: a }
|
|
160
|
+
: a && typeof a === "object"
|
|
161
|
+
? { ...(a["@id"] && byId(a["@id"])), ...a }
|
|
162
|
+
: null,
|
|
163
|
+
)
|
|
164
|
+
.filter(Boolean);
|
|
165
|
+
// Bylines in the markup: rel="author", and class or itemprop "author" or "byline" (not a comment's author). A product
|
|
166
|
+
// page's itemprop="author" is usually a customer's review, so it isn't a byline there.
|
|
167
|
+
const marked =
|
|
168
|
+
shop && !article
|
|
169
|
+
? []
|
|
170
|
+
: [
|
|
171
|
+
...body.matchAll(
|
|
172
|
+
/<([a-z][\w-]*)\b([^>]*\b(?:class|itemprop|rel)\s*=\s*["']?[^"'>]*\b(?:authors?|byline)\b[^>]*)>([\s\S]*?)<\/\1>/gi,
|
|
173
|
+
),
|
|
174
|
+
].filter(m => !/comment/i.test(m[2]));
|
|
175
|
+
// A byline's first link is the author's; later ones are usually its category or date archive.
|
|
176
|
+
const authorLink = h =>
|
|
177
|
+
linksIn(h)
|
|
178
|
+
.map(l => l.href)
|
|
179
|
+
.find(h => abs(h));
|
|
180
|
+
const outLinks = uniq(
|
|
181
|
+
linksIn(main)
|
|
182
|
+
.filter(l => !/\bsponsored\b/i.test(attr(l.a, "rel") || ""))
|
|
183
|
+
.map(l => abs(l.href))
|
|
184
|
+
.filter(u => u && bare(u.hostname) !== own && !SOCIAL.test(bare(u.hostname)))
|
|
185
|
+
.map(u => bare(u.hostname)),
|
|
186
|
+
10,
|
|
187
|
+
);
|
|
188
|
+
const mainText = textOf(main),
|
|
189
|
+
stat = mainText.match(STAT);
|
|
190
|
+
// Any Organization subtype counts, a HairSalon or Bakery too.
|
|
191
|
+
const org = nodes.filter(n => typesOf(n).some(isBusinessType));
|
|
192
|
+
const forms = [...body.matchAll(/<form\b([^>]*)>([\s\S]*?)<\/form>/gi)];
|
|
193
|
+
return {
|
|
194
|
+
about: [...to(ABOUT_SEG, ABOUT_TXT), ...(types.includes("AboutPage") ? [selfPath] : [])].slice(0, 3),
|
|
195
|
+
contact: uniq([
|
|
196
|
+
...to(CONTACT_SEG, CONTACT_TXT),
|
|
197
|
+
...(types.includes("ContactPage") ? [selfPath] : []),
|
|
198
|
+
links.some(l => /^mailto:/i.test(l.href) || /\/cdn-cgi\/l\/email-protection/i.test(l.href)) && "an email link",
|
|
199
|
+
links.some(l => /^tel:/i.test(l.href)) && "a phone link",
|
|
200
|
+
/[\w.+-]+@[\w-]+(\.[\w-]+)*\.[a-z]{2,}\b/i.test(textOf(body)) && "an email address",
|
|
201
|
+
]),
|
|
202
|
+
authorByline: uniq([
|
|
203
|
+
...authors.map(a => (typeof a.name === "string" && a.name.trim()) || "author in the Article schema"),
|
|
204
|
+
...marked.map(m => textOf(m[3]).slice(0, 60)),
|
|
205
|
+
]),
|
|
206
|
+
authorPage: uniq([
|
|
207
|
+
...authors.map(a => typeof a.url === "string" && a.url),
|
|
208
|
+
...nodes.filter(n => typesOf(n).includes("Person")).map(n => typeof n.url === "string" && n.url),
|
|
209
|
+
...[...html.matchAll(/<(?:a|link)\b([^>]*\brel\s*=\s*["']?[^"'>]*\bauthor\b[^>]*)>/gi)]
|
|
210
|
+
.map(m => attr(m[1], "href"))
|
|
211
|
+
.filter(h => h && abs(h) && !/\.txt$/i.test(h)),
|
|
212
|
+
...marked.map(m => authorLink(m[3])),
|
|
213
|
+
(types.includes("ProfilePage") || AUTHOR_PATH.test(selfPath)) && selfPath,
|
|
214
|
+
]),
|
|
215
|
+
dateShown: uniq([
|
|
216
|
+
...nodes.flatMap(n => [n.datePublished, n.dateModified]).filter(d => typeof d === "string"),
|
|
217
|
+
...[...body.matchAll(/<time\b([^>]*)>([\s\S]*?)<\/time>/gi)].map(m => attr(m[1], "datetime") || textOf(m[2])),
|
|
218
|
+
...[...body.matchAll(/<[a-z]+\b([^>]*\bitemprop\s*=\s*["']?(?:datePublished|dateModified)\b[^>]*)>/gi)].map(
|
|
219
|
+
m => attr(m[1], "content") || attr(m[1], "datetime"),
|
|
220
|
+
),
|
|
221
|
+
mainText.match(DATE_TXT)?.[0],
|
|
222
|
+
]),
|
|
223
|
+
outLinks,
|
|
224
|
+
proof: uniq([
|
|
225
|
+
nodes.some(n =>
|
|
226
|
+
deepHas(
|
|
227
|
+
n,
|
|
228
|
+
o =>
|
|
229
|
+
"aggregateRating" in o || "review" in o || typesOf(o).some(t => t === "AggregateRating" || t === "Review"),
|
|
230
|
+
),
|
|
231
|
+
) && "reviews in the schema",
|
|
232
|
+
...[...body.matchAll(/<h[1-6]\b[^>]*>([\s\S]*?)<\/h[1-6]>/gi)]
|
|
233
|
+
.map(m => textOf(m[1]))
|
|
234
|
+
.filter(t => PROOF_TXT.test(words(t))),
|
|
235
|
+
...to(PROOF_SEG, PROOF_TXT),
|
|
236
|
+
REVIEW_WIDGET.test(html) && "a reviews widget",
|
|
237
|
+
]),
|
|
238
|
+
policies: Object.fromEntries(Object.entries(POLICY).map(([k, [seg, txt]]) => [k, to(seg, txt)[0] || null])),
|
|
239
|
+
ownMedia: uniq(
|
|
240
|
+
[...main.matchAll(/<(?:img|video|source)\b([^>]*)>/gi)]
|
|
241
|
+
.map(m => ({
|
|
242
|
+
src: attr(m[1], "src") || attr(m[1], "data-src") || (attr(m[1], "srcset") || "").trim().split(/[\s,]+/)[0],
|
|
243
|
+
w: attr(m[1], "width"),
|
|
244
|
+
h: attr(m[1], "height"),
|
|
245
|
+
}))
|
|
246
|
+
.filter(
|
|
247
|
+
i =>
|
|
248
|
+
i.src &&
|
|
249
|
+
!/^data:/i.test(i.src) &&
|
|
250
|
+
i.w !== "1" &&
|
|
251
|
+
i.h !== "1" &&
|
|
252
|
+
abs(i.src) &&
|
|
253
|
+
!STOCK.test(abs(i.src).hostname),
|
|
254
|
+
)
|
|
255
|
+
.map(i => i.src),
|
|
256
|
+
),
|
|
257
|
+
articleLike:
|
|
258
|
+
article ||
|
|
259
|
+
nodes.some(n => typeof n.datePublished === "string") ||
|
|
260
|
+
self.some(s => /^(blog|news|articles)$/.test(s)),
|
|
261
|
+
shopLike: shop,
|
|
262
|
+
// A form with a field for the visitor's own data: not a search box, a button, a hidden field or a choice.
|
|
263
|
+
collectsData: forms.some(
|
|
264
|
+
([, a, inner]) =>
|
|
265
|
+
!/\brole\s*=\s*["']?search|\baction\s*=\s*["']?[^"'\s>]*search/i.test(a) &&
|
|
266
|
+
[...inner.matchAll(/<(input|textarea)\b([^>]*)>/gi)].some(
|
|
267
|
+
([, tag, at]) =>
|
|
268
|
+
(tag.toLowerCase() === "textarea" ||
|
|
269
|
+
!/^(hidden|submit|button|reset|image|search|checkbox|radio|range|color|number)$/i.test(
|
|
270
|
+
attr(at, "type") || "text",
|
|
271
|
+
)) &&
|
|
272
|
+
!/^(q|s|query|search|search_query|keywords?|term)$/i.test(attr(at, "name") || ""),
|
|
273
|
+
),
|
|
274
|
+
),
|
|
275
|
+
// Google recommends name, logo and sameAs on the home page or the page about the organization.
|
|
276
|
+
// https://developers.google.com/search/docs/appearance/structured-data/organization
|
|
277
|
+
org: org.length
|
|
278
|
+
? {
|
|
279
|
+
name: org.map(n => n.name).find(v => typeof v === "string" && v.trim()) || null,
|
|
280
|
+
logo: org.map(n => n.logo).find(Boolean) || null,
|
|
281
|
+
sameAs: [...new Set(org.flatMap(n => [].concat(n.sameAs || [])).filter(s => typeof s === "string"))],
|
|
282
|
+
}
|
|
283
|
+
: null,
|
|
284
|
+
unsourcedStat: stat && !outLinks.length && !CITED.test(mainText) ? stat[0] : null,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// [id, label, rule, what to add]. Labels read in a list: "missing: author pages, sources cited".
|
|
289
|
+
const SIGNALS = [
|
|
290
|
+
[
|
|
291
|
+
"about",
|
|
292
|
+
"About page",
|
|
293
|
+
"TRUST-04",
|
|
294
|
+
"Add an About page that says who runs the site and why visitors can trust it, and link it from the main menu or the footer.",
|
|
295
|
+
],
|
|
296
|
+
[
|
|
297
|
+
"contact",
|
|
298
|
+
"Contact details",
|
|
299
|
+
"TRUST-04",
|
|
300
|
+
"Add a Contact page, or show an email address or phone number, and link it from every page.",
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
"org-schema",
|
|
304
|
+
"Organization schema",
|
|
305
|
+
"SCHEMA-02",
|
|
306
|
+
"Add Organization schema (or your business type) to the home page with the business's `name`, `logo` and `sameAs` links to its official profiles.",
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
"author-byline",
|
|
310
|
+
"Author names",
|
|
311
|
+
"CONTENT-07",
|
|
312
|
+
"Name the author on each article, on the page and as `author` in its Article schema.",
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
"author-page",
|
|
316
|
+
"Author pages",
|
|
317
|
+
"CONTENT-07",
|
|
318
|
+
"Link each author's name to a page about them (role, experience, credentials), and give the author a `url` in the schema.",
|
|
319
|
+
],
|
|
320
|
+
[
|
|
321
|
+
"dates",
|
|
322
|
+
"Dates on articles",
|
|
323
|
+
"CONTENT-07",
|
|
324
|
+
"Show when each article was published or last reviewed, and add `datePublished` and `dateModified` to its schema. Change them only with real edits (CONTENT-12).",
|
|
325
|
+
],
|
|
326
|
+
["sources", "Sources cited", "CONTENT-10", "Link the source next to each fact and figure in your content."],
|
|
327
|
+
[
|
|
328
|
+
"customer-proof",
|
|
329
|
+
"Customer reviews",
|
|
330
|
+
"TRUST-05",
|
|
331
|
+
"Show real reviews, testimonials or case studies from customers. Only real ones count: never invent or edit them.",
|
|
332
|
+
],
|
|
333
|
+
["policies", "Policies", "TRUST-03", ""],
|
|
334
|
+
[
|
|
335
|
+
"https",
|
|
336
|
+
"HTTPS and security headers",
|
|
337
|
+
"TRUST-01",
|
|
338
|
+
"Serve every page over HTTPS and fix the open security findings (TRUST-01, TRUST-07).",
|
|
339
|
+
],
|
|
340
|
+
[
|
|
341
|
+
"own-media",
|
|
342
|
+
"Own images",
|
|
343
|
+
null,
|
|
344
|
+
"Use your own photos, screenshots or diagrams on content pages, rather than none or stock photos.",
|
|
345
|
+
],
|
|
346
|
+
];
|
|
347
|
+
const POLICY_NAME = { privacy: "a privacy policy", terms: "terms of service", returns: "a returns policy" };
|
|
348
|
+
const list = xs => (xs.length > 1 ? `${xs.slice(0, -1).join(", ")} and ${xs.at(-1)}` : xs[0] || "");
|
|
349
|
+
|
|
350
|
+
// site: { origin, https (null when unknown), localHeaders (a local crawl's missing security headers), orgSchema,
|
|
351
|
+
// unsourcedStats (null when unknown) }. Author signals apply only with articles, terms only where the site sells or
|
|
352
|
+
// collects data, returns only on shops.
|
|
353
|
+
export function trustSignals(pages, site) {
|
|
354
|
+
const own = hostOf(site.origin);
|
|
355
|
+
const T = pages.filter(p => p?.trust).map(p => ({ ...p.trust, at: pathOf(p.finalUrl || p.url || "") }));
|
|
356
|
+
const first = get => {
|
|
357
|
+
for (const t of T) {
|
|
358
|
+
const v = [].concat(get(t) || []).find(Boolean);
|
|
359
|
+
if (v) return `${v} on ${t.at}`;
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
};
|
|
363
|
+
const articles = T.some(t => t.articleLike),
|
|
364
|
+
shop = T.some(t => t.shopLike),
|
|
365
|
+
collects = T.some(t => t.collectsData);
|
|
366
|
+
const org = site.orgSchema,
|
|
367
|
+
orgHas = org ? ["name", "logo", "sameAs"].filter(k => [].concat(org[k] || []).length) : [];
|
|
368
|
+
const orgLacks = ["name", "logo", "sameAs"].filter(k => !orgHas.includes(k));
|
|
369
|
+
const need = ["privacy", ...(shop || collects ? ["terms"] : []), ...(shop ? ["returns"] : [])];
|
|
370
|
+
const policy = Object.fromEntries(need.map(k => [k, first(t => t.policies?.[k])])),
|
|
371
|
+
lacking = need.filter(k => !policy[k]);
|
|
372
|
+
const outside = first(t => (t.outLinks || []).filter(h => h !== own && !h.endsWith("." + own)));
|
|
373
|
+
const stat = site.unsourcedStats ? first(t => t.unsourcedStat && `“${t.unsourcedStat}” with no source`) : null;
|
|
374
|
+
const sig = {
|
|
375
|
+
about: { found: first(t => t.about) },
|
|
376
|
+
contact: { found: first(t => t.contact) },
|
|
377
|
+
"org-schema": org
|
|
378
|
+
? {
|
|
379
|
+
found: !orgLacks.length && `${list(orgHas)} in the Organization schema`,
|
|
380
|
+
evidence: `the Organization schema has no ${list(orgLacks)}`,
|
|
381
|
+
add: !orgLacks.length
|
|
382
|
+
? null
|
|
383
|
+
: `Add ${list(orgLacks.map(k => `\`${k}\``))} to the Organization schema on the home page.`,
|
|
384
|
+
}
|
|
385
|
+
: { evidence: "no Organization schema" },
|
|
386
|
+
"author-byline": { applies: articles, found: first(t => t.authorByline) },
|
|
387
|
+
"author-page": { applies: articles, found: first(t => t.authorPage) },
|
|
388
|
+
dates: { applies: articles, found: first(t => t.dateShown) },
|
|
389
|
+
sources: { found: !stat && outside && `links to ${outside}`, evidence: stat },
|
|
390
|
+
"customer-proof": { found: first(t => t.proof) },
|
|
391
|
+
policies: {
|
|
392
|
+
found: !lacking.length && need.map(k => policy[k]).join(" · "),
|
|
393
|
+
evidence: lacking.length ? `no link to ${list(lacking.map(k => POLICY_NAME[k]))}` : null,
|
|
394
|
+
add: `Add ${list(lacking.length ? lacking.map(k => POLICY_NAME[k]) : need.map(k => POLICY_NAME[k]))} and link ${lacking.length === 1 || need.length === 1 ? "it" : "them"} from the footer.`,
|
|
395
|
+
},
|
|
396
|
+
https:
|
|
397
|
+
site.https == null
|
|
398
|
+
? { applies: false, evidence: "can't be told from a local crawl: pass --site-origin" }
|
|
399
|
+
: {
|
|
400
|
+
found:
|
|
401
|
+
site.https &&
|
|
402
|
+
`${site.origin}${site.localHeaders ? "; its missing security headers were read from a local build, which may lack the ones production adds" : ", with no open security findings"}`,
|
|
403
|
+
evidence: /^https:/.test(site.origin)
|
|
404
|
+
? "HTTPS, with open security findings"
|
|
405
|
+
: "the site isn't served over HTTPS",
|
|
406
|
+
},
|
|
407
|
+
"own-media": { found: first(t => t.ownMedia) },
|
|
408
|
+
};
|
|
409
|
+
return SIGNALS.map(([id, label, rule, add]) => {
|
|
410
|
+
const s = sig[id];
|
|
411
|
+
return {
|
|
412
|
+
id,
|
|
413
|
+
label,
|
|
414
|
+
rule,
|
|
415
|
+
applies: s.applies ?? true,
|
|
416
|
+
found: !!s.found,
|
|
417
|
+
evidence: s.found || s.evidence || null,
|
|
418
|
+
add: s.add || add,
|
|
419
|
+
};
|
|
420
|
+
});
|
|
421
|
+
}
|