search-visibility 1.2.0 → 1.3.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/CHANGELOG.md +43 -0
- package/README.es.md +39 -3
- package/README.ja.md +39 -3
- package/README.ko.md +47 -10
- package/README.md +47 -10
- package/README.zh.md +39 -3
- package/package.json +2 -1
- package/skills/seo-orchestrator/scripts/ai-performance.mjs +107 -0
- package/skills/seo-orchestrator/scripts/canonical.mjs +175 -0
- package/skills/seo-orchestrator/scripts/command.mjs +6 -0
- package/skills/seo-orchestrator/scripts/comparison-pairs.mjs +89 -0
- package/skills/seo-orchestrator/scripts/crawl-report.mjs +34 -0
- package/skills/seo-orchestrator/scripts/fetch-page.mjs +2 -5
- package/skills/seo-orchestrator/scripts/hreflang.mjs +273 -0
- package/skills/seo-orchestrator/scripts/html.mjs +7 -80
- package/skills/seo-orchestrator/scripts/index-status.mjs +181 -0
- package/skills/seo-orchestrator/scripts/indexing.mjs +28 -39
- package/skills/seo-orchestrator/scripts/internal-crawl.mjs +16 -46
- package/skills/seo-orchestrator/scripts/link-header.mjs +93 -0
- package/skills/seo-orchestrator/scripts/mcp.mjs +45 -8
- package/skills/seo-orchestrator/scripts/naver-advisor.mjs +147 -0
- package/skills/seo-orchestrator/scripts/observations.mjs +42 -8
- package/skills/seo-orchestrator/scripts/report-html.mjs +35 -0
- package/skills/seo-orchestrator/scripts/report-input.mjs +142 -0
- package/skills/seo-orchestrator/scripts/report-sources.mjs +202 -0
- package/skills/seo-orchestrator/scripts/robots.mjs +270 -0
- package/skills/seo-orchestrator/scripts/scope.mjs +185 -0
- package/skills/seo-orchestrator/scripts/search-performance.mjs +1 -1
- package/skills/seo-orchestrator/scripts/seo-check.mjs +203 -263
- package/skills/seo-orchestrator/scripts/site-audit.mjs +102 -46
- package/skills/seo-orchestrator/scripts/structured-data.mjs +316 -0
- package/skills/seo-orchestrator/scripts/url-inspection.mjs +150 -0
- package/skills/seo-orchestrator/scripts/visibility-comparison.mjs +218 -39
- package/skills/seo-orchestrator/scripts/visibility-report.mjs +71 -48
- package/skills/seo-orchestrator/scripts/visibility.mjs +53 -50
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// canonical 선언 판정. CLI·웹·확장 공용이며 Node 전용 API를 쓰지 않는다.
|
|
2
|
+
// 브라우저 확장은 이 파일의 사본(extension/canonical.mjs)을 읽는다.
|
|
3
|
+
import { normalizeEscapes } from "./link-header.mjs";
|
|
4
|
+
|
|
5
|
+
const MAX_LISTED = 10;
|
|
6
|
+
const MAX_DECLARATIONS = 50;
|
|
7
|
+
|
|
8
|
+
export function httpUrl(value, base) {
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(value, base || undefined);
|
|
11
|
+
return ["https:", "http:"].includes(url.protocol) ? url.href : null;
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 로컬 파일은 배포 호스트와 디렉터리를 모릅니다. 확정되는 URL 부분만 비교합니다.
|
|
18
|
+
function canonicalTargetsCanAgree(values, scheme) {
|
|
19
|
+
const fullUrls = new Set();
|
|
20
|
+
const rootedPaths = new Set();
|
|
21
|
+
const searches = new Set();
|
|
22
|
+
const hashes = new Set();
|
|
23
|
+
let longestSuffix = "";
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
const ref = value.replace(/[\t\n\r]/g, "").replaceAll("\\", "/");
|
|
26
|
+
const url = new URL(value, `${scheme}://example.invalid/`);
|
|
27
|
+
const hasAuthority = /^(?:https?:)?\/\//i.test(ref);
|
|
28
|
+
if (hasAuthority) fullUrls.add(url.href);
|
|
29
|
+
hashes.add(url.hash);
|
|
30
|
+
if (!ref.startsWith("#")) searches.add(url.search);
|
|
31
|
+
if (/^[?#]/.test(ref)) continue; // 배포 페이지의 경로를 그대로 상속합니다.
|
|
32
|
+
if (hasAuthority || ref.startsWith("/")) rootedPaths.add(url.pathname);
|
|
33
|
+
// 상대 경로가 ../를 포함해도 루트에서 해석한 끝부분은 항상 동일합니다.
|
|
34
|
+
const suffix = url.pathname;
|
|
35
|
+
if (!longestSuffix.endsWith(suffix)) {
|
|
36
|
+
if (!suffix.endsWith(longestSuffix)) return false;
|
|
37
|
+
longestSuffix = suffix;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const [rootedPath] = rootedPaths;
|
|
41
|
+
return fullUrls.size <= 1 && rootedPaths.size <= 1 && searches.size <= 1 && hashes.size <= 1
|
|
42
|
+
&& (!rootedPath || rootedPath.endsWith(longestSuffix));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const canonicalBase = (baseHref, pageUrl) => (baseHref ? httpUrl(baseHref, pageUrl) || pageUrl : pageUrl);
|
|
46
|
+
|
|
47
|
+
// 퍼센트 인코딩 표기만 다른 URL은 하나로 모은다.
|
|
48
|
+
function distinct(urls) {
|
|
49
|
+
const known = new Map();
|
|
50
|
+
for (const url of urls) {
|
|
51
|
+
const key = normalizeEscapes(url);
|
|
52
|
+
if (!known.has(key)) known.set(key, url);
|
|
53
|
+
}
|
|
54
|
+
return [...known.values()];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 같은 HTTP 응답에서 읽은 canonical 선언을 출처별로 보존한다. 선언이 지나치게 많으면 앞부분만 남긴다.
|
|
58
|
+
export function canonicalDeclarations(page, pageUrl, linkHeader = []) {
|
|
59
|
+
const base = canonicalBase(page.baseHref, pageUrl);
|
|
60
|
+
// 같은 선언의 반복은 하나로 합친 뒤 상한을 적용한다.
|
|
61
|
+
const unique = (links) => [...new Map(links.map((link) => [link.href, link])).values()];
|
|
62
|
+
const html = unique((page.canonicalLinks ?? []).filter((link) => link.inHead));
|
|
63
|
+
const header = unique(linkHeader.filter((link) => link.rels.includes("canonical")));
|
|
64
|
+
const omitted = Math.max(0, html.length - MAX_DECLARATIONS) + Math.max(0, header.length - MAX_DECLARATIONS);
|
|
65
|
+
return {
|
|
66
|
+
html: html.slice(0, MAX_DECLARATIONS).map(({ href }) => ({ href: href ?? "", url: href?.trim() ? httpUrl(href.trim(), base) : null })),
|
|
67
|
+
header: header.slice(0, MAX_DECLARATIONS).map(({ href, url }) => ({ href, url })),
|
|
68
|
+
...(omitted && { omitted }),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// links: [{ href, inHead }] — 한 개의 유효한 대상을 확인했을 때만 target을 돌려준다.
|
|
73
|
+
export function evaluateCanonical({ links = [], baseHref = null, pageUrl = null, linkHeader = [] }) {
|
|
74
|
+
const findings = [];
|
|
75
|
+
const counts = new Map();
|
|
76
|
+
const add = (level, code, data = {}) => {
|
|
77
|
+
const count = (counts.get(code) ?? 0) + 1;
|
|
78
|
+
counts.set(code, count);
|
|
79
|
+
if (count <= MAX_LISTED) findings.push({ level, code, ...data });
|
|
80
|
+
};
|
|
81
|
+
const done = (target = null) => {
|
|
82
|
+
for (const [code, count] of counts) {
|
|
83
|
+
if (count > MAX_LISTED) findings.push({ level: "INFO", code: "omitted", value: code, count: count - MAX_LISTED });
|
|
84
|
+
}
|
|
85
|
+
return { findings, target };
|
|
86
|
+
};
|
|
87
|
+
const headLinks = links.filter((link) => link.inHead);
|
|
88
|
+
const header = linkHeader.filter((link) => link.rels.includes("canonical"));
|
|
89
|
+
for (const { href, url } of header.slice(0, MAX_DECLARATIONS)) {
|
|
90
|
+
if (!url) add("FAIL", "header-invalid", { value: href });
|
|
91
|
+
}
|
|
92
|
+
const headerTargets = distinct(header.map((link) => link.url).filter(Boolean));
|
|
93
|
+
if (headerTargets.length > 1) add("FAIL", "header-conflict", { values: headerTargets });
|
|
94
|
+
if (links.length > headLinks.length) add("FAIL", "outside-head");
|
|
95
|
+
const elsewhere = (target) => {
|
|
96
|
+
if (pageUrl && target && normalizeEscapes(target) !== normalizeEscapes(httpUrl(pageUrl) ?? "")) add("INFO", "elsewhere", { value: target });
|
|
97
|
+
return done(target ?? null);
|
|
98
|
+
};
|
|
99
|
+
if (!headLinks.length) {
|
|
100
|
+
if (headerTargets.length === 1) {
|
|
101
|
+
add("INFO", "header-declared", { value: headerTargets[0] });
|
|
102
|
+
return elsewhere(headerTargets[0]);
|
|
103
|
+
}
|
|
104
|
+
if (!links.length && !header.length) add("WARN", "missing");
|
|
105
|
+
return done();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const base = canonicalBase(baseHref, pageUrl);
|
|
109
|
+
const targets = new Map();
|
|
110
|
+
const unresolved = new Set();
|
|
111
|
+
const problems = new Set();
|
|
112
|
+
for (const { href } of headLinks) {
|
|
113
|
+
const value = href?.trim();
|
|
114
|
+
// 같은 값의 선언은 한 번만 판정한다.
|
|
115
|
+
if (problems.has(value ?? "")) continue;
|
|
116
|
+
problems.add(value ?? "");
|
|
117
|
+
if (!value) {
|
|
118
|
+
add("FAIL", "empty");
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const relative = !/^[a-z][a-z\d+.\-]*:/i.test(value);
|
|
122
|
+
const url = httpUrl(value, base);
|
|
123
|
+
if (relative && !base && httpUrl(value, "https://example.invalid/")) {
|
|
124
|
+
add("WARN", "relative-nobase", { value });
|
|
125
|
+
unresolved.add(value);
|
|
126
|
+
} else if (!url) {
|
|
127
|
+
add("FAIL", "invalid", { value });
|
|
128
|
+
} else {
|
|
129
|
+
if (relative) add("WARN", "relative", { value, url });
|
|
130
|
+
const key = normalizeEscapes(url);
|
|
131
|
+
if (!targets.has(key)) targets.set(key, url);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const declarations = [...targets.values(), ...unresolved];
|
|
135
|
+
if (declarations.length > 1 && !["https", "http"].some((scheme) => canonicalTargetsCanAgree(declarations, scheme))) {
|
|
136
|
+
add("FAIL", "conflict", { values: declarations });
|
|
137
|
+
return done();
|
|
138
|
+
}
|
|
139
|
+
if (headLinks.length > 1) add("WARN", targets.size + unresolved.size === 1 ? "duplicate" : "multiple");
|
|
140
|
+
if (unresolved.size) return done();
|
|
141
|
+
const [target] = targets.values();
|
|
142
|
+
if (headerTargets.length && target) {
|
|
143
|
+
if (headerTargets.length > 1 || normalizeEscapes(headerTargets[0]) !== normalizeEscapes(target)) {
|
|
144
|
+
add("FAIL", "header-differs", { value: target, values: headerTargets });
|
|
145
|
+
return done();
|
|
146
|
+
}
|
|
147
|
+
add("INFO", "header-agrees");
|
|
148
|
+
}
|
|
149
|
+
return elsewhere(target);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function describeCanonical({ code, value, url, count, values = [] }, locale) {
|
|
153
|
+
const pick = (ko, en) => (locale === "en" ? en : ko);
|
|
154
|
+
const listed = values.slice(0, MAX_LISTED).join(", ") +
|
|
155
|
+
(values.length > MAX_LISTED ? pick(` 외 ${values.length - MAX_LISTED}개`, ` and ${values.length - MAX_LISTED} more`) : "");
|
|
156
|
+
switch (code) {
|
|
157
|
+
case "header-invalid": return `${pick("HTTP Link 헤더의 canonical이 잘못된 HTTP(S) URL", "Invalid HTTP(S) canonical URL in the HTTP Link header")}: ${value}`;
|
|
158
|
+
case "header-conflict": return `${pick("HTTP Link 헤더에 서로 다른 canonical", "Conflicting canonical URLs in the HTTP Link header")}: ${listed}`;
|
|
159
|
+
case "outside-head": return pick("<head> 밖의 canonical 선언은 무시됨", "Canonical declarations outside <head> are ignored");
|
|
160
|
+
case "header-declared": return `${pick("HTTP Link 헤더로 선언", "Declared in the HTTP Link header")}: ${value}`;
|
|
161
|
+
case "omitted": return pick(`같은 유형의 canonical 지적 ${count}건 생략 (${value})`, `${count} more canonical findings of the same kind omitted (${value})`);
|
|
162
|
+
case "missing": return pick("없음", "Missing");
|
|
163
|
+
case "empty": return pick("href가 없거나 비어 있음", "Missing or empty href");
|
|
164
|
+
case "relative-nobase": return pick(`상대 경로: ${value} (기준 URL이 없어 최종 주소 미확인)`, `Relative path: ${value} (no base URL to resolve it)`);
|
|
165
|
+
case "invalid": return pick(`잘못된 HTTP(S) URL: ${value}`, `Invalid HTTP(S) URL: ${value}`);
|
|
166
|
+
case "relative": return `${pick("상대 경로", "Relative path")}: ${value} → ${url}`;
|
|
167
|
+
case "conflict": return `${pick("서로 다른 대표 URL 선언", "Conflicting canonical URLs")}: ${listed}`;
|
|
168
|
+
case "duplicate": return pick("canonical 중복 선언 — 한 태그만 유지 권장", "Duplicate canonical declarations. Keep one tag");
|
|
169
|
+
case "multiple": return pick("canonical 선언이 여러 개 — 대상 URL 확인 필요", "Multiple canonical declarations. Check the target URLs");
|
|
170
|
+
case "header-differs": return `${pick("HTML과 HTTP Link 헤더의 canonical이 다름", "HTML and HTTP Link header canonicals differ")}: HTML ${value} · Link ${listed}`;
|
|
171
|
+
case "header-agrees": return pick("HTML과 HTTP Link 헤더의 canonical이 일치", "HTML and HTTP Link header canonicals agree");
|
|
172
|
+
case "elsewhere": return `${pick("다른 URL을 가리킴", "Points to another URL")}: ${value}`;
|
|
173
|
+
default: return code;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// 복사해 셸에 붙여 넣는 확인 명령. 웹은 이 함수의 소스를 페이지에 그대로 넣으므로 바깥 값을 참조하지 않는다.
|
|
2
|
+
// URL은 sh·zsh·PowerShell·cmd에서 한 인수가 되도록 큰따옴표로 감싸고, 큰따옴표 안에서도 해석되는 문자는 퍼센트 인코딩한다.
|
|
3
|
+
export function verifyCommand(url, lang, excluded) {
|
|
4
|
+
const quoted = '"' + String(url).replace(/[$`\\"!\s]/g, (char) => encodeURIComponent(char).replace("!", "%21")) + '"';
|
|
5
|
+
return "npx search-visibility " + quoted + " --crawl --max-pages 40 --fail-on-findings" + (excluded ? " --expect-excluded" : "") + " --lang " + (lang === "ko" ? "ko" : "en");
|
|
6
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// 전후 AI 답변을 수집 조건이 같은 쌍으로 맞춘다. 중복 회차는 임의 순서로 짝짓지 않는다.
|
|
2
|
+
const REQUIRED = ["query", "mode", "locale", "region", "run"];
|
|
3
|
+
|
|
4
|
+
const blank = (value) => value === undefined || value === null || value === "";
|
|
5
|
+
|
|
6
|
+
function pairKey(record) {
|
|
7
|
+
const text = (value) => String(value).normalize("NFC").trim();
|
|
8
|
+
return JSON.stringify([text(record.query), text(record.mode).toLowerCase(), text(record.locale).toLowerCase(), text(record.region).toLowerCase(), record.run]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function index(records) {
|
|
12
|
+
const keyed = new Map();
|
|
13
|
+
const incomplete = [];
|
|
14
|
+
for (const record of records) {
|
|
15
|
+
const fields = REQUIRED.filter((field) => blank(record[field]));
|
|
16
|
+
if (fields.length) incomplete.push({ record, fields });
|
|
17
|
+
else {
|
|
18
|
+
const key = pairKey(record);
|
|
19
|
+
keyed.set(key, [...(keyed.get(key) ?? []), record]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { keyed, incomplete };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function rates(pairs, side) {
|
|
26
|
+
const records = pairs.map((pair) => pair[side]);
|
|
27
|
+
const rate = (field) => (records.length && pairs.every((pair) => typeof pair.before[field] === "boolean" && typeof pair.after[field] === "boolean")
|
|
28
|
+
? records.filter((record) => record[field]).length / records.length : null);
|
|
29
|
+
return { mentionRate: rate("mentioned"), citationRate: rate("cited") };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 같은 조건·회차라도 양쪽에서 모델이 모두 기록되고 서로 다르면 모델별 관측으로 나눈다.
|
|
33
|
+
function splitByModel(first, last) {
|
|
34
|
+
for (const key of new Set([...first.keyed.keys(), ...last.keyed.keys()])) {
|
|
35
|
+
const sides = [first, last].map((side) => side.keyed.get(key) ?? []);
|
|
36
|
+
if (!sides.some((records) => records.length > 1)) continue;
|
|
37
|
+
const separable = sides.every((records) => records.every((record) => !blank(record.model)) && new Set(records.map((record) => record.model)).size === records.length);
|
|
38
|
+
if (!separable) continue;
|
|
39
|
+
for (const side of [first, last]) {
|
|
40
|
+
for (const record of side.keyed.get(key) ?? []) side.keyed.set(`${key}\u0000${record.model}`, [record]);
|
|
41
|
+
side.keyed.delete(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function pairObservations(beforeRecords, afterRecords) {
|
|
47
|
+
const first = index(beforeRecords);
|
|
48
|
+
const last = index(afterRecords);
|
|
49
|
+
splitByModel(first, last);
|
|
50
|
+
const duplicated = new Set([first, last].flatMap(({ keyed }) => [...keyed].filter(([, records]) => records.length > 1).map(([key]) => key)));
|
|
51
|
+
const count = (side, key) => side.keyed.get(key)?.length ?? 0;
|
|
52
|
+
const pairs = [];
|
|
53
|
+
const onlyBefore = [];
|
|
54
|
+
const onlyAfter = [];
|
|
55
|
+
let modelDiffers = 0;
|
|
56
|
+
let modelMissing = 0;
|
|
57
|
+
const unverified = { before: first.incomplete.length, after: last.incomplete.length };
|
|
58
|
+
let duplicates = 0;
|
|
59
|
+
for (const key of new Set([...first.keyed.keys(), ...last.keyed.keys()])) {
|
|
60
|
+
if (duplicated.has(key)) {
|
|
61
|
+
unverified.before += count(first, key);
|
|
62
|
+
unverified.after += count(last, key);
|
|
63
|
+
duplicates += count(first, key) + count(last, key);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const before = first.keyed.get(key)?.[0];
|
|
67
|
+
const after = last.keyed.get(key)?.[0];
|
|
68
|
+
if (!after) onlyBefore.push(before);
|
|
69
|
+
else if (!before) onlyAfter.push(after);
|
|
70
|
+
else if (blank(before.model) !== blank(after.model)) {
|
|
71
|
+
modelMissing++;
|
|
72
|
+
unverified.before++;
|
|
73
|
+
unverified.after++;
|
|
74
|
+
} else if (!blank(before.model) && before.model !== after.model) modelDiffers++;
|
|
75
|
+
else pairs.push({ before, after });
|
|
76
|
+
}
|
|
77
|
+
const missingFields = [...new Set([...first.incomplete, ...last.incomplete].flatMap(({ fields }) => fields))];
|
|
78
|
+
const reasons = [
|
|
79
|
+
...(missingFields.length ? [{ code: "missing-conditions", count: first.incomplete.length + last.incomplete.length, fields: missingFields }] : []),
|
|
80
|
+
...(duplicates ? [{ code: "duplicate-runs", count: duplicates }] : []),
|
|
81
|
+
...(modelMissing ? [{ code: "missing-model", count: modelMissing }] : []),
|
|
82
|
+
...(modelDiffers ? [{ code: "model-differs", count: modelDiffers }] : []),
|
|
83
|
+
];
|
|
84
|
+
return {
|
|
85
|
+
pairs, reasons, unverified, modelDiffers,
|
|
86
|
+
onlyBefore: onlyBefore.length, onlyAfter: onlyAfter.length,
|
|
87
|
+
beforeRates: rates(pairs, "before"), afterRates: rates(pairs, "after"),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// 내부 링크 크롤링 결과의 요약 문구. 보고서를 브라우저에서도 만들 수 있게 네트워크 코드와 분리한다.
|
|
2
|
+
import { t } from "./locale.mjs";
|
|
3
|
+
|
|
4
|
+
export function crawlSummary(report) {
|
|
5
|
+
const { visited, brokenLinks, redirectChains, orphanPages, orphanCheckComplete } = report;
|
|
6
|
+
const orphans = orphanCheckComplete ? orphanPages.length : t("판정 보류", "not assessed");
|
|
7
|
+
return t(
|
|
8
|
+
`내부 링크 크롤링 · 방문 ${visited.length} · 깨진 링크 ${brokenLinks.length} · 리다이렉트 체인·루프 ${redirectChains.length} · 고아 페이지 ${orphans}`,
|
|
9
|
+
`Internal link crawl · Visited ${visited.length} · Broken links ${brokenLinks.length} · Redirect chains and loops ${redirectChains.length} · Orphan pages ${orphans}`,
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function crawlLines(report) {
|
|
14
|
+
const rows = [crawlSummary(report)];
|
|
15
|
+
if (report.startStatus != null) rows.push(`${report.start} · HTTP ${report.startStatus}`);
|
|
16
|
+
if (report.truncated) rows.push(t("크롤링 한도에 도달했습니다.", "Crawl limit reached."));
|
|
17
|
+
for (const url of report.blocked) rows.push(t("robots.txt 차단", "Blocked by robots.txt") + ` · ${url}`);
|
|
18
|
+
for (const { url, status, finalUrl, sources } of report.brokenLinks) {
|
|
19
|
+
rows.push(t("깨진 링크", "Broken link") + ` · HTTP ${status} · ${url}${url === finalUrl ? "" : ` → ${finalUrl}`} · ${sources.join(", ")}`);
|
|
20
|
+
}
|
|
21
|
+
const reasons = {
|
|
22
|
+
loop: t("루프", "Loop"), limit: t("홉 한도", "Hop limit"), blocked: t("robots.txt 차단", "Blocked by robots.txt"),
|
|
23
|
+
external: t("다른 출처", "Off-origin"), invalid: t("잘못된 주소", "Invalid URL"),
|
|
24
|
+
};
|
|
25
|
+
for (const { chain, issue, destination } of report.redirectChains) {
|
|
26
|
+
const steps = chain.map(({ status, url }) => `${status} ${url}`);
|
|
27
|
+
if (issue && destination) steps.push(destination);
|
|
28
|
+
rows.push(t("리다이렉트", "Redirect") + ` · ${steps.join(" → ")}${issue ? ` · ${reasons[issue]}` : ""}`);
|
|
29
|
+
}
|
|
30
|
+
for (const url of report.orphanPages) rows.push(t("고아 페이지", "Orphan page") + ` · ${url}`);
|
|
31
|
+
for (const { url, error } of report.errors) rows.push(`${url} · ${error}`);
|
|
32
|
+
for (const warning of report.sitemap.warnings) rows.push(warning);
|
|
33
|
+
return rows;
|
|
34
|
+
}
|
|
@@ -59,11 +59,8 @@ export async function fetchResource(url, userAgent, { allowedOrigin, maxBytes, s
|
|
|
59
59
|
current = new URL(response.headers.location, current);
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
if (response.rawHeaders[i].toLowerCase() === "x-robots-tag") robotsHeaders.push(response.rawHeaders[i + 1]);
|
|
65
|
-
}
|
|
66
|
-
const metadata = { status, headers: response.headers, robotsHeaders, chain, finalUrl: current.href };
|
|
62
|
+
const headerLines = name => response.rawHeaders.filter((_, i) => i % 2 && response.rawHeaders[i - 1].toLowerCase() === name);
|
|
63
|
+
const metadata = { status, headers: response.headers, robotsHeaders: headerLines("x-robots-tag"), linkHeaders: headerLines("link"), chain, finalUrl: current.href };
|
|
67
64
|
if (!(typeof readBody === "function" ? readBody(metadata) : readBody)) {
|
|
68
65
|
response.destroy();
|
|
69
66
|
return metadata;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// hreflang 선언 수집과 언어별 URL 연결 판정. CLI·웹·확장 공용이며 Node 전용 API를 쓰지 않는다.
|
|
2
|
+
// 브라우저 확장은 이 파일의 사본(extension/hreflang.mjs)을 읽는다.
|
|
3
|
+
import { comparableUrl, webUrlOrNull } from "./link-header.mjs";
|
|
4
|
+
|
|
5
|
+
const LANGUAGES = new Set(("aa ab ae af ak am an ar as av ay az ba be bg bh bi bm bn bo br bs ca ce ch co cr cs cu cv cy da de dv dz ee el en eo es et eu fa ff fi fj fo fr fy " +
|
|
6
|
+
"ga gd gl gn gu gv ha he hi ho hr ht hu hy hz ia id ie ig ii ik io is it iu ja jv ka kg ki kj kk kl km kn ko kr ks ku kv kw ky la lb lg li ln lo lt lu lv mg mh mi mk ml mn mr ms mt my " +
|
|
7
|
+
"na nb nd ne ng nl nn no nr nv ny oc oj om or os pa pi pl ps pt qu rm rn ro ru rw sa sc sd se sg si sk sl sm sn so sq sr ss st su sv sw ta te tg th ti tk tl tn to tr ts tt tw ty " +
|
|
8
|
+
"ug uk ur uz ve vi vo wa wo xh yi yo za zh zu").split(" "));
|
|
9
|
+
const REGIONS = new Set(("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ " +
|
|
10
|
+
"DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP " +
|
|
11
|
+
"KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM " +
|
|
12
|
+
"PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ " +
|
|
13
|
+
"UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW").split(" "));
|
|
14
|
+
|
|
15
|
+
let scriptNames;
|
|
16
|
+
function knownScript(script) {
|
|
17
|
+
const code = script[0].toUpperCase() + script.slice(1).toLowerCase();
|
|
18
|
+
try {
|
|
19
|
+
scriptNames ??= new Intl.DisplayNames(["en"], { type: "script", fallback: "none" });
|
|
20
|
+
return Boolean(scriptNames.of(code));
|
|
21
|
+
} catch {
|
|
22
|
+
return true; // 목록을 제공하지 않는 런타임에서는 형식만 확인한다.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// x-default 또는 언어(ISO 639-1)[-문자(ISO 15924)][-지역(ISO 3166-1 alpha-2)]
|
|
27
|
+
export function validHreflang(code) {
|
|
28
|
+
const value = String(code ?? "").trim().toLowerCase();
|
|
29
|
+
if (value === "x-default") return true;
|
|
30
|
+
const match = /^([a-z]{2})(?:-([a-z]{4}))?(?:-([a-z]{2}))?$/.exec(value);
|
|
31
|
+
if (!match) return false;
|
|
32
|
+
const [, language, script, region] = match;
|
|
33
|
+
return LANGUAGES.has(language) && (!script || knownScript(script)) && (!region || REGIONS.has(region.toUpperCase()));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function declaration(source, lang, href, extra) {
|
|
37
|
+
const absolute = typeof href === "string" && /^https?:\/\//i.test(href.trim()) ? webUrlOrNull(href.trim()) : null;
|
|
38
|
+
return {
|
|
39
|
+
source, lang: String(lang ?? "").trim().toLowerCase(), href: href ?? "",
|
|
40
|
+
url: absolute ? comparableUrl(absolute) : null, ...extra,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// page: 선언이 적혀 있던 페이지.
|
|
45
|
+
export function pageDeclarations({ html = [], linkHeader = [], page = null } = {}) {
|
|
46
|
+
return [
|
|
47
|
+
...html.map(({ lang, href }) => declaration("html", lang, href, { page })),
|
|
48
|
+
...linkHeader.filter((link) => link.rels.includes("alternate"))
|
|
49
|
+
.flatMap((link) => link.hreflang.map((lang) => declaration("http-header", lang, link.href, { page }))),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const usable = (entry) => Boolean(entry.url) && validHreflang(entry.lang);
|
|
54
|
+
|
|
55
|
+
const MAX_KEPT = 500;
|
|
56
|
+
// 판정에는 전체 선언을 쓰고, 보고서와 API 응답에는 앞부분과 생략 수만 남긴다.
|
|
57
|
+
export function keptDeclarations(declarations) {
|
|
58
|
+
const omitted = declarations.length - MAX_KEPT;
|
|
59
|
+
return omitted > 0 ? { declarations: declarations.slice(0, MAX_KEPT), omitted } : { declarations };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const unique = (values) => [...new Set(values)];
|
|
63
|
+
// 선언이 지나치게 많은 페이지에서 지적과 목록이 끝없이 늘지 않게 한다.
|
|
64
|
+
const MAX_PER_CODE = 50;
|
|
65
|
+
|
|
66
|
+
// 지역만 다른 변형(en-US, en-GB)은 같은 언어로 본다. 문자(zh-Hans, zh-Hant)는 구분한다.
|
|
67
|
+
const language = (code) => code.replace(/-[a-z]{2}$/, "");
|
|
68
|
+
|
|
69
|
+
// 대상 URL → 그 URL을 선언한 언어와 출처. 한 번만 순회해 만든다.
|
|
70
|
+
function targetsOf(declarations) {
|
|
71
|
+
const targets = new Map();
|
|
72
|
+
for (const entry of declarations) {
|
|
73
|
+
if (!usable(entry)) continue;
|
|
74
|
+
if (!targets.has(entry.url)) targets.set(entry.url, new Map());
|
|
75
|
+
const languages = targets.get(entry.url);
|
|
76
|
+
if (!languages.has(entry.lang)) languages.set(entry.lang, new Set());
|
|
77
|
+
languages.get(entry.lang).add(entry.source);
|
|
78
|
+
}
|
|
79
|
+
return targets;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* pages: [{ url, requested, status, error, noindex, canonicals, declarations }]
|
|
84
|
+
* url은 최종 응답 URL이며 로컬 파일은 null.
|
|
85
|
+
* scope: { singlePage, truncated, sitemapDeclarations: Map<url, declaration[]> }
|
|
86
|
+
* 반환: 입력과 같은 순서의 지적 배열
|
|
87
|
+
*/
|
|
88
|
+
export function analyzeHreflang(pages, { singlePage = false, truncated = false, sitemapDeclarations = new Map() } = {}) {
|
|
89
|
+
const byUrl = new Map();
|
|
90
|
+
const byRequested = new Map();
|
|
91
|
+
for (const page of pages) {
|
|
92
|
+
if (page.url && !byUrl.has(page.url)) byUrl.set(page.url, page);
|
|
93
|
+
if (page.requested && !byRequested.has(page.requested)) byRequested.set(page.requested, page);
|
|
94
|
+
}
|
|
95
|
+
const cache = new Map();
|
|
96
|
+
const cached = (key, build) => {
|
|
97
|
+
if (!cache.has(key)) cache.set(key, build());
|
|
98
|
+
return cache.get(key);
|
|
99
|
+
};
|
|
100
|
+
const declaredBy = (page) => cached(page, () => targetsOf(page.declarations ?? []));
|
|
101
|
+
const sitemapTargets = (url) => cached(`sitemap ${url}`, () => targetsOf(sitemapDeclarations.get(url) ?? []));
|
|
102
|
+
const selfLanguages = (page) => {
|
|
103
|
+
const languages = [...(declaredBy(page).get(page.url)?.keys() ?? [])];
|
|
104
|
+
return languages.length > 1 ? languages.filter((lang) => lang !== "x-default") : languages;
|
|
105
|
+
};
|
|
106
|
+
const targetProblem = (url) => {
|
|
107
|
+
const direct = byUrl.get(url);
|
|
108
|
+
const moved = byRequested.get(url);
|
|
109
|
+
if (moved && !moved.error && moved.url && moved.url !== url) return { page: moved, problem: "redirect", final: moved.url };
|
|
110
|
+
const page = direct ?? moved;
|
|
111
|
+
if (!page) return { page: null };
|
|
112
|
+
if (page.error) return { page, problem: "fetch-error" };
|
|
113
|
+
if (page.status !== 200) return { page, problem: "http-error", status: page.status };
|
|
114
|
+
return { page };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return pages.map((page) => {
|
|
118
|
+
const findings = [];
|
|
119
|
+
const counts = new Map();
|
|
120
|
+
const add = (code, level, item, data = {}) => {
|
|
121
|
+
const count = (counts.get(code) ?? 0) + 1;
|
|
122
|
+
counts.set(code, count);
|
|
123
|
+
if (count <= MAX_PER_CODE) findings.push({ code, level, item, ...data });
|
|
124
|
+
};
|
|
125
|
+
const done = () => {
|
|
126
|
+
for (const [code, count] of counts) {
|
|
127
|
+
if (count > MAX_PER_CODE) findings.push({ code: "omitted", level: "INFO", item: "hreflang", of: code, count: count - MAX_PER_CODE });
|
|
128
|
+
}
|
|
129
|
+
return findings;
|
|
130
|
+
};
|
|
131
|
+
const declarations = page.declarations ?? [];
|
|
132
|
+
if (page.error || !declarations.length || (page.url && page.status !== 200)) return done();
|
|
133
|
+
|
|
134
|
+
const reported = new Set();
|
|
135
|
+
for (const entry of declarations) {
|
|
136
|
+
const key = `${entry.lang}\u0000${entry.href}`;
|
|
137
|
+
if (reported.has(key)) continue;
|
|
138
|
+
if (!validHreflang(entry.lang)) add("invalid-code", "WARN", "hreflang", { lang: entry.lang, source: entry.source, target: entry.href });
|
|
139
|
+
else if (!entry.url) add("not-absolute", "WARN", "hreflang", { lang: entry.lang, source: entry.source, target: entry.href });
|
|
140
|
+
else continue;
|
|
141
|
+
reported.add(key);
|
|
142
|
+
}
|
|
143
|
+
const targets = declaredBy(page);
|
|
144
|
+
const byLanguage = new Map();
|
|
145
|
+
for (const [url, languages] of targets) {
|
|
146
|
+
for (const [lang, sources] of languages) {
|
|
147
|
+
if (!byLanguage.has(lang)) byLanguage.set(lang, []);
|
|
148
|
+
byLanguage.get(lang).push({ url, sources: [...sources] });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const [lang, matches] of byLanguage) {
|
|
152
|
+
if (matches.length > 1) add("conflict", "WARN", "hreflang", { lang, targets: matches });
|
|
153
|
+
}
|
|
154
|
+
if (!declarations.some((entry) => entry.lang === "x-default")) add("x-default", "INFO", "hreflang x-default");
|
|
155
|
+
if (!page.url) {
|
|
156
|
+
add("local-file", "INFO", "hreflang unverified");
|
|
157
|
+
return done();
|
|
158
|
+
}
|
|
159
|
+
if (page.requested && page.requested !== page.url && declarations.some((entry) => entry.source === "sitemap" && entry.page === page.requested)) {
|
|
160
|
+
add("page-redirect", "WARN", "hreflang target", { target: page.requested, final: page.url });
|
|
161
|
+
}
|
|
162
|
+
if (!targets.has(page.url)) add("missing-self", "WARN", "hreflang self", { target: page.url });
|
|
163
|
+
|
|
164
|
+
const languages = selfLanguages(page);
|
|
165
|
+
const unverified = new Map();
|
|
166
|
+
const defer = (reason, url) => {
|
|
167
|
+
if (!unverified.has(reason)) unverified.set(reason, []);
|
|
168
|
+
unverified.get(reason).push(url);
|
|
169
|
+
};
|
|
170
|
+
for (const [url, declaredLanguages] of targets) {
|
|
171
|
+
if (url === page.url) continue;
|
|
172
|
+
const declared = [...declaredLanguages.keys()];
|
|
173
|
+
const returns = (back) => {
|
|
174
|
+
const found = back.get(page.url);
|
|
175
|
+
return Boolean(found) && (!languages.length || languages.some((lang) => found.has(lang)));
|
|
176
|
+
};
|
|
177
|
+
const { page: target, problem, final, status } = targetProblem(url);
|
|
178
|
+
if (problem === "redirect") add("target-redirect", "WARN", "hreflang target", { target: url, final });
|
|
179
|
+
else if (problem === "http-error") add("target-http-error", "WARN", "hreflang target", { target: url, status });
|
|
180
|
+
else if (problem === "fetch-error") defer("fetch-error", url);
|
|
181
|
+
else if (!target) {
|
|
182
|
+
// 읽은 사이트맵에 상대 URL의 반환 선언이 있으면 선언 관계는 확인된다.
|
|
183
|
+
if (!returns(sitemapTargets(url))) defer(singlePage ? "single-page" : truncated ? "limit" : "outside-sample", url);
|
|
184
|
+
} else {
|
|
185
|
+
if (target.noindex) add("target-noindex", "WARN", "hreflang target", { target: url });
|
|
186
|
+
const canonical = (target.canonicals ?? []).filter((value) => value !== url);
|
|
187
|
+
if (canonical.length) add("target-canonical", "WARN", "hreflang target", { target: url, final: canonical.slice(0, 10).join(", ") });
|
|
188
|
+
const own = selfLanguages(target).filter((lang) => lang !== "x-default");
|
|
189
|
+
const wanted = declared.filter((lang) => lang !== "x-default");
|
|
190
|
+
const mismatch = own.length ? wanted.filter((lang) => !own.includes(lang)) : [];
|
|
191
|
+
if (mismatch.length) add("target-language", "WARN", "hreflang target", { target: url, lang: mismatch.join(", "), final: own.join(", ") });
|
|
192
|
+
if (!returns(declaredBy(target))) add("missing-return", "WARN", "hreflang reciprocity", { target: url, source: page.url });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (const [reason, urls] of unverified) add("unverified", "INFO", "hreflang unverified", { reason, targets: urls });
|
|
196
|
+
|
|
197
|
+
const own = new Set(languages.map(language));
|
|
198
|
+
for (const canonical of page.canonicals ?? []) {
|
|
199
|
+
if (canonical === page.url) continue;
|
|
200
|
+
const other = [...(targets.get(canonical)?.keys() ?? [])].filter((lang) => lang !== "x-default" && !own.has(language(lang)));
|
|
201
|
+
if (own.size && other.length) add("canonical-language", "WARN", "canonical target", { target: canonical, lang: other.join(", ") });
|
|
202
|
+
const { page: target, problem, final, status } = targetProblem(canonical);
|
|
203
|
+
if (problem === "redirect") add("canonical-redirect", "WARN", "canonical target", { target: canonical, final });
|
|
204
|
+
else if (problem === "http-error") add("canonical-http-error", "WARN", "canonical target", { target: canonical, status });
|
|
205
|
+
else if (target?.noindex) add("canonical-noindex", "WARN", "canonical target", { target: canonical });
|
|
206
|
+
}
|
|
207
|
+
return done();
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const pick = (locale, ko, en) => (locale === "en" ? en : ko);
|
|
212
|
+
|
|
213
|
+
export function sourceName(source, locale) {
|
|
214
|
+
return {
|
|
215
|
+
html: "HTML <head>",
|
|
216
|
+
"http-header": pick(locale, "HTTP Link 헤더", "HTTP Link header"),
|
|
217
|
+
sitemap: pick(locale, "XML 사이트맵", "XML sitemap"),
|
|
218
|
+
}[source];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const MAX_LISTED = 20;
|
|
222
|
+
function listed(values, locale, separator = ", ") {
|
|
223
|
+
const rest = values.length - MAX_LISTED;
|
|
224
|
+
return values.slice(0, MAX_LISTED).join(separator) + (rest > 0 ? pick(locale, ` 외 ${rest}개`, ` and ${rest} more`) : "");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function describeHreflang(finding, locale) {
|
|
228
|
+
const { code, lang, target, final, status, source } = finding;
|
|
229
|
+
const reasons = () => ({
|
|
230
|
+
"single-page": pick(locale, "단일 URL 점검이라 상대 페이지를 수집하지 않음", "single-URL audit; counterpart pages were not collected"),
|
|
231
|
+
limit: pick(locale, "수집 한도에 도달해 상대 페이지를 점검하지 않음", "collection limit reached before the counterpart was audited"),
|
|
232
|
+
"outside-sample": pick(locale, "이번 수집 범위 밖의 페이지", "outside the collected sample"),
|
|
233
|
+
"fetch-error": pick(locale, "상대 페이지 수집 실패", "the counterpart could not be fetched"),
|
|
234
|
+
})[finding.reason];
|
|
235
|
+
switch (code) {
|
|
236
|
+
case "invalid-code": return pick(locale, `잘못된 언어 코드 "${lang || "(비어 있음)"}" → ${target} (${sourceName(source, locale)}). ko, en-CA, zh-Hant, x-default 형식을 사용하세요.`,
|
|
237
|
+
`Invalid language code "${lang || "(empty)"}" → ${target} (${sourceName(source, locale)}). Use forms such as ko, en-CA, zh-Hant or x-default.`);
|
|
238
|
+
case "not-absolute": return pick(locale, `${lang}: 인증정보 없는 HTTP(S) 절대 URL이 필요합니다: ${target || "(비어 있음)"} (${sourceName(source, locale)})`,
|
|
239
|
+
`${lang}: an absolute HTTP(S) URL without credentials is required: ${target || "(empty)"} (${sourceName(source, locale)})`);
|
|
240
|
+
case "omitted": return pick(locale, `같은 유형의 hreflang 지적 ${finding.count}건을 생략했습니다 (${finding.of}).`, `${finding.count} more hreflang findings of the same kind were omitted (${finding.of}).`);
|
|
241
|
+
case "conflict": {
|
|
242
|
+
const list = listed(finding.targets.map(({ url, sources }) => `${url} (${sources.map((name) => sourceName(name, locale)).join(", ")})`), locale, " · ");
|
|
243
|
+
return pick(locale, `${lang} 하나가 서로 다른 URL을 가리킵니다: ${list}`, `${lang} points to different URLs: ${list}`);
|
|
244
|
+
}
|
|
245
|
+
case "x-default": return pick(locale, "x-default 선언 없음(선택). 일치하는 언어가 없는 사용자를 위한 기본 URL이 필요하면 추가하세요.",
|
|
246
|
+
"No x-default declaration (optional). Add one to name a fallback URL for unmatched languages.");
|
|
247
|
+
case "local-file": return pick(locale, "로컬 파일은 배포 URL을 알 수 없어 자기 참조와 상호 참조를 확인하지 않았습니다.",
|
|
248
|
+
"Self and return references are unverified because a local file has no deployment URL.");
|
|
249
|
+
case "missing-self": return pick(locale, `자기 자신(${target})을 가리키는 hreflang 선언이 없습니다.`, `No hreflang declaration points back to this page (${target}).`);
|
|
250
|
+
case "missing-return": return pick(locale, `${target} 페이지에 ${source}의 언어에 맞는 hreflang 반환 링크가 없습니다.`, `${target} has no hreflang return link to ${source} for the source language.`);
|
|
251
|
+
case "unverified": return pick(locale, `상호 참조 미확인 (${reasons()}): ${listed(finding.targets, locale)}`, `Return references unverified (${reasons()}): ${listed(finding.targets, locale)}`);
|
|
252
|
+
case "page-redirect": return pick(locale, `사이트맵이 언어 대안을 선언한 페이지 ${target}이 ${final}(으)로 리다이렉트됩니다.`, `The sitemap declares alternates on ${target}, which redirects to ${final}.`);
|
|
253
|
+
case "target-redirect": return pick(locale, `대체 URL ${target}이 ${final}(으)로 리다이렉트됩니다.`, `Alternate URL ${target} redirects to ${final}.`);
|
|
254
|
+
case "target-http-error": return pick(locale, `대체 URL ${target}이 HTTP ${status}를 반환합니다.`, `Alternate URL ${target} returns HTTP ${status}.`);
|
|
255
|
+
case "target-noindex": return pick(locale, `대체 URL ${target}에 색인 제외 지시가 있습니다.`, `Alternate URL ${target} has an exclusion directive.`);
|
|
256
|
+
case "target-canonical": return pick(locale, `대체 URL ${target}의 canonical이 다른 주소(${final})를 가리킵니다.`, `Alternate URL ${target} declares a different canonical (${final}).`);
|
|
257
|
+
case "target-language": return pick(locale, `${target}을 ${lang}(으)로 선언했지만 그 페이지는 자신을 ${final}(으)로 선언합니다.`, `${target} is declared as ${lang}, but it declares itself as ${final}.`);
|
|
258
|
+
case "canonical-language": return pick(locale, `canonical이 다른 언어(${lang}) 버전을 가리킵니다: ${target}`, `The canonical points to another language version (${lang}): ${target}`);
|
|
259
|
+
case "canonical-redirect": return pick(locale, `canonical 대상 ${target}이 ${final}(으)로 리다이렉트됩니다.`, `Canonical target ${target} redirects to ${final}.`);
|
|
260
|
+
case "canonical-http-error": return pick(locale, `canonical 대상 ${target}이 HTTP ${status}를 반환합니다.`, `Canonical target ${target} returns HTTP ${status}.`);
|
|
261
|
+
case "canonical-noindex": return pick(locale, `canonical 대상 ${target}에 색인 제외 지시가 있습니다.`, `Canonical target ${target} has an exclusion directive.`);
|
|
262
|
+
default: return code;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function summarizeDeclarations(declarations, locale) {
|
|
267
|
+
const bySource = ["html", "http-header", "sitemap"]
|
|
268
|
+
.map((source) => [source, declarations.filter((entry) => entry.source === source).length])
|
|
269
|
+
.filter(([, count]) => count)
|
|
270
|
+
.map(([source, count]) => `${sourceName(source, locale)} ${count}`).join(", ");
|
|
271
|
+
const languages = listed(unique(declarations.map((entry) => entry.lang).filter(Boolean)), locale);
|
|
272
|
+
return pick(locale, `선언 ${declarations.length}개 (${languages}) · 출처: ${bySource}`, `${declarations.length} declarations (${languages}) · Sources: ${bySource}`);
|
|
273
|
+
}
|