@v-office/site-checks 0.4.1 → 0.4.2

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/README.md CHANGED
@@ -208,12 +208,12 @@ unrelated findings, `match` picks one.
208
208
  | `listing-noindex` | error | A page that lists rentals (the search page's `data-prerendered-results` container, the `SearchResults` island, or `listingPages`) that is noindex. Waits while every page is noindex. | Take the page out of the noindex routes. |
209
209
  | `listing-links` | warning | A page that lists rentals that carries no links to rentals in its HTML, so a crawler without JavaScript sees an empty list. Runs once some listing has links or the build has more than ten pages; a warning because the links come from the PMS feed. | Render the list server-side, or list the page in `listingClientOnly` with the reason. |
210
210
  | `sitemap-noindex` | error | A sitemap entry whose page says noindex (waits while every page is noindex) or is not in the build; an `llms.txt` link to a page that is not there. Skipped without a sitemap and `llms.txt`. | Make the sitemap filter and the noindex routes agree; fix the link. |
211
- | `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats. A missing one is `page-metadata`. | Shorten; give each page its own. |
211
+ | `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats (language versions naming each other as `hreflang` alternates do not count). A missing one is `page-metadata`. | Shorten; give each page its own. |
212
212
  | `canonical-link` | error | On the launched site (a production site URL, some indexable page): an indexable page without an absolute `<link rel="canonical">`. | Build it from the Astro `site` and the page path. |
213
213
  | `open-graph` | warning | On the launched site: an indexable page without an absolute `og:url` and `og:image`. | Add them, absolute. |
214
214
  | `trailing-slash` | warning | On the launched site: `trailingSlash` is not `"never"`. | Set `trailingSlash: "never"`; write internal links without a trailing slash. |
215
215
  | `v9-production-hub` | warning | v9 only, on the launched site: the build's env does not call the production Hub (`CMS_STAGE=production` or the production Hub URLs); a committed `.env.local`; a committed `HUB_API_KEY` equal to `.env.local`'s. Waits for a production site URL and an indexable page. | Set the production stage or URLs and the customer's production key; untrack `.env.local`. |
216
- | `page-structure` | warning | One `<h1>`, no skipped heading level, no flood of `<h3>` under few `<h2>`, a `<main>`, `alt` on every image, a label on every control, a caption and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
216
+ | `page-structure` | warning | One `<h1>`, no skipped heading level, no flood of `<h3>` under few `<h2>`, a `<main>`, `alt` on every image, a label on every control, a caption (or `aria-label`/`aria-labelledby`) and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
217
217
  | `load-order` | warning | At start: an on-demand library (map, chart, 3D) in the start-up code, a start-up chunk over 150 KB compressed, photos after the first in card swipe strips with a URL, a first-paint photo from 100 KB up in one size only, a preloaded swap face without a `size-adjust` stand-in. | `import()` on demand; first slide only; width `srcset`; a `local()` stand-in. |
218
218
  | `banned-copy` | warning | A `bannedCopy` wording in a page's visible text. Skipped without configured wordings. | Reword. |
219
219
  | `duplicate-sentences` | warning | The same sentence rendered twice on one page. Waits while every page is noindex. | Remove one, or list it in `allowDuplicateSentences`. |
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as cli } from "./cli-CYG52KHL.mjs";
2
+ import { n as cli } from "./cli-AmQJK-Qj.mjs";
3
3
  //#region src/bin.ts
4
4
  process.exitCode = await cli(process.argv.slice(2), {
5
5
  out: (line) => console.log(line),
@@ -1311,13 +1311,112 @@ const loadOrder = {
1311
1311
  }
1312
1312
  };
1313
1313
  //#endregion
1314
+ //#region src/checks/sitemapNoindex.ts
1315
+ const SITEMAP_INDEX = "sitemap-index.xml";
1316
+ const LLMS = "llms.txt";
1317
+ /** A URL path as the sitemap checks compare it: query and fragment dropped, escapes decoded, no
1318
+ * trailing slash but the root's. */
1319
+ const normalize = (urlPath) => {
1320
+ let p = urlPath.split(/[?#]/, 1)[0] ?? "";
1321
+ try {
1322
+ p = decodeURIComponent(p);
1323
+ } catch {}
1324
+ return p.length > 1 ? p.replace(/\/+$/, "") : p;
1325
+ };
1326
+ /** `https://www.example.de/a/` and `/a/` → `/a`. */
1327
+ const toPath = (loc) => {
1328
+ const value = loc.trim();
1329
+ try {
1330
+ return normalize(new URL(value).pathname);
1331
+ } catch {
1332
+ return normalize(value);
1333
+ }
1334
+ };
1335
+ const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)].map((m) => xmlText(m[1]));
1336
+ /** The URL lists the build publishes agree with the pages it built: no sitemap entry whose own page
1337
+ * says noindex or is not in the build, no `llms.txt` link to a page that is not there. Skipped when
1338
+ * the build publishes neither. While every page is noindex (a site before launch, under its blanket
1339
+ * robots meta), a sitemap listing them is not refused: that disagreement ends with the launch. */
1340
+ const sitemapNoindex = {
1341
+ id: "sitemap-noindex",
1342
+ title: "Published URL lists match the built pages",
1343
+ severity: "error",
1344
+ stage: "dist",
1345
+ begin: (ctx) => {
1346
+ if (!ctx.hasDist) return null;
1347
+ const start = ctx.has(SITEMAP_INDEX) ? [SITEMAP_INDEX] : ctx.files.filter((f) => /^sitemap[^/]*\.xml$/.test(f));
1348
+ if (start.length === 0 && !ctx.has(LLMS)) return null;
1349
+ const noindex = /* @__PURE__ */ new Map();
1350
+ let indexable = 0;
1351
+ return {
1352
+ visit: (page) => {
1353
+ if (page.redirect) return;
1354
+ if (page.noindex) noindex.set(normalize(page.url), page.path);
1355
+ else indexable += 1;
1356
+ },
1357
+ finish: () => {
1358
+ const findings = [];
1359
+ const sitemaps = new Map(start.map((file) => [file, ""]));
1360
+ for (const [sitemap, index] of sitemaps) {
1361
+ if (!ctx.has(sitemap)) {
1362
+ findings.push({
1363
+ path: index,
1364
+ message: `The sitemap index names ${sitemap}, which is not in the build.`
1365
+ });
1366
+ continue;
1367
+ }
1368
+ const xml = ctx.read(sitemap);
1369
+ if (/<sitemapindex\b/i.test(xml)) {
1370
+ for (const loc of locs(xml)) {
1371
+ const child = toPath(loc).replace(/^\//, "");
1372
+ if (!sitemaps.has(child)) sitemaps.set(child, sitemap);
1373
+ }
1374
+ continue;
1375
+ }
1376
+ for (const loc of locs(xml)) {
1377
+ const urlPath = toPath(loc);
1378
+ if (!ctx.serves(urlPath)) findings.push({
1379
+ path: sitemap,
1380
+ message: `The sitemap lists ${loc}, which is not in the build.`
1381
+ });
1382
+ else if (indexable > 0 && noindex.has(urlPath)) findings.push({
1383
+ path: sitemap,
1384
+ message: `The sitemap lists ${loc}, whose page says noindex: the sitemap filter and the noindex routes disagree.`
1385
+ });
1386
+ }
1387
+ }
1388
+ if (ctx.has(LLMS)) for (const match of ctx.read(LLMS).matchAll(/\]\(([^)\s]+)\)/g)) {
1389
+ const link = match[1];
1390
+ if (/^[a-z][a-z0-9+.-]*:/i.test(link) && !ctx.config.site) continue;
1391
+ if (/^[a-z][a-z0-9+.-]*:/i.test(link)) {
1392
+ let host;
1393
+ try {
1394
+ host = new URL(link).host;
1395
+ } catch {
1396
+ continue;
1397
+ }
1398
+ if (host !== new URL(ctx.config.site).host) continue;
1399
+ }
1400
+ if (!ctx.serves(toPath(link))) findings.push({
1401
+ path: LLMS,
1402
+ message: `llms.txt links ${link}, which is not in the build.`
1403
+ });
1404
+ }
1405
+ return findings;
1406
+ }
1407
+ };
1408
+ }
1409
+ };
1410
+ //#endregion
1314
1411
  //#region src/checks/pageHeads.ts
1315
1412
  const MAX_TITLE = 60;
1316
1413
  const MAX_DESCRIPTION = 160;
1317
1414
  /** The head of every indexable page as a search result shows it: a title over 60 or a description
1318
1415
  * over 160 characters is cut, an empty description is replaced by whatever the crawler picks, and a
1319
- * title or description another page repeats makes the two compete. A missing title or description
1320
- * is the build worker's `page-metadata` finding, not repeated here. A warning: the page works. */
1416
+ * title or description another page repeats makes the two compete. Language versions of one page
1417
+ * that name each other as `<link rel="alternate" hreflang>` do not compete: a search engine shows
1418
+ * the one in the searcher's language. A missing title or description is the build worker's
1419
+ * `page-metadata` finding, not repeated here. A warning: the page works. */
1321
1420
  const pageHeads = {
1322
1421
  id: "page-heads",
1323
1422
  title: "Titles and descriptions of indexable pages",
@@ -1326,12 +1425,24 @@ const pageHeads = {
1326
1425
  begin: (ctx) => {
1327
1426
  if (!ctx.hasDist) return null;
1328
1427
  const findings = [];
1428
+ /** Each page's URL path, and the URL paths it names as hreflang alternates. Any origin: the
1429
+ * links are absolute on the production host, also in a preview build, and a match needs both
1430
+ * pages to name each other. */
1431
+ const urls = /* @__PURE__ */ new Map();
1432
+ const alternates = /* @__PURE__ */ new Map();
1329
1433
  const titles = /* @__PURE__ */ new Map();
1330
1434
  const descriptions = /* @__PURE__ */ new Map();
1331
1435
  const remember = (map, value, path) => map.set(value, [...map.get(value) ?? [], path]);
1332
1436
  return {
1333
1437
  visit: (page) => {
1334
1438
  if (page.redirect || page.noindex || page.path === "404.html") return;
1439
+ const own = normalize(page.url);
1440
+ urls.set(page.path, own);
1441
+ const named = /* @__PURE__ */ new Set();
1442
+ for (const link of page.document.querySelectorAll("link[rel~=\"alternate\"][hreflang][href]")) try {
1443
+ named.add(normalize(resolveReference(page, link.getAttribute("href") ?? "")));
1444
+ } catch {}
1445
+ if (named.size > 0) alternates.set(own, named);
1335
1446
  const title = page.document.querySelector("title")?.textContent?.trim();
1336
1447
  const description = page.document.querySelector("meta[name=\"description\"]")?.getAttribute("content")?.trim();
1337
1448
  if (title) {
@@ -1354,8 +1465,24 @@ const pageHeads = {
1354
1465
  }
1355
1466
  },
1356
1467
  finish: () => {
1468
+ const mutual = (a, b) => {
1469
+ const [ua, ub] = [urls.get(a), urls.get(b)];
1470
+ return !!alternates.get(ua)?.has(ub) && !!alternates.get(ub)?.has(ua);
1471
+ };
1472
+ /** The pages that compete for one value: one per group of language versions, where every
1473
+ * page of a group names every other one and is named back. */
1474
+ const competing = (paths) => {
1475
+ const groups = [];
1476
+ for (const path of paths) {
1477
+ const group = groups.find((members) => members.every((other) => mutual(path, other)));
1478
+ if (group) group.push(path);
1479
+ else groups.push([path]);
1480
+ }
1481
+ return groups.map((group) => group[0]);
1482
+ };
1357
1483
  const duplicates = (map, what) => {
1358
- for (const [value, pages] of map) {
1484
+ for (const [value, all] of map) {
1485
+ const pages = all.length < 2 ? all : competing(all);
1359
1486
  if (pages.length < 2) continue;
1360
1487
  const shown = pages.slice(0, 3).join(", ");
1361
1488
  const more = pages.length > 3 ? ` (+${pages.length - 3} more)` : "";
@@ -1422,7 +1549,7 @@ const structureFaults = (page) => {
1422
1549
  if (unlabelled.length > 0) faults.set("control-label", `${unlabelled.length} control(s) without a label: ${unlabelled.slice(0, 3).map((c) => `<${c.tagName.toLowerCase()}${c.getAttribute("id") ? ` #${c.getAttribute("id")}` : ""}>`).join(", ")}`);
1423
1550
  const tables = inDocument(page, "table").flatMap((table) => {
1424
1551
  const problems = [];
1425
- if (!table.querySelector("caption")) problems.push("no <caption>");
1552
+ if (!["aria-label", "aria-labelledby"].some((a) => table.getAttribute(a)?.trim()) && !table.querySelector("caption")) problems.push("no <caption> or aria-label");
1426
1553
  const headers = [...table.querySelectorAll("th")];
1427
1554
  if (headers.length === 0) problems.push("no <th>");
1428
1555
  else if (!headers.some((th) => th.hasAttribute("scope"))) problems.push("<th> without scope");
@@ -1433,10 +1560,10 @@ const structureFaults = (page) => {
1433
1560
  };
1434
1561
  /** The built pages' own structure, which a screen reader navigates by and nothing else reads: one
1435
1562
  * `<h1>`, no skipped heading level, a `<main>` landmark, `alt` on every image, a label on every
1436
- * control, a caption and scoped headers on every table, and no flood of small headings under few
1437
- * sections. Contrast, focus order and keyboard traps are not decidable from static markup. A
1438
- * warning: the alt text of feed photos and the headings of feed text come from the PMS. A site
1439
- * declines a rule in `structureIgnore`. */
1563
+ * control, a caption (or `aria-label`/`aria-labelledby`) and scoped headers on every table, and
1564
+ * no flood of small headings under few sections. Contrast, focus order and keyboard traps are not
1565
+ * decidable from static markup. A warning: the alt text of feed photos and the headings of feed
1566
+ * text come from the PMS. A site declines a rule in `structureIgnore`. */
1440
1567
  const pageStructure = {
1441
1568
  id: "page-structure",
1442
1569
  title: "Page outline, landmarks, alt text, labels and tables",
@@ -1702,101 +1829,6 @@ const rentalFacts = {
1702
1829
  }
1703
1830
  };
1704
1831
  //#endregion
1705
- //#region src/checks/sitemapNoindex.ts
1706
- const SITEMAP_INDEX = "sitemap-index.xml";
1707
- const LLMS = "llms.txt";
1708
- const normalize = (urlPath) => {
1709
- let p = urlPath.split(/[?#]/, 1)[0] ?? "";
1710
- try {
1711
- p = decodeURIComponent(p);
1712
- } catch {}
1713
- return p.length > 1 ? p.replace(/\/+$/, "") : p;
1714
- };
1715
- /** `https://www.example.de/a/` and `/a/` → `/a`. */
1716
- const toPath = (loc) => {
1717
- const value = loc.trim();
1718
- try {
1719
- return normalize(new URL(value).pathname);
1720
- } catch {
1721
- return normalize(value);
1722
- }
1723
- };
1724
- const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)].map((m) => xmlText(m[1]));
1725
- /** The URL lists the build publishes agree with the pages it built: no sitemap entry whose own page
1726
- * says noindex or is not in the build, no `llms.txt` link to a page that is not there. Skipped when
1727
- * the build publishes neither. While every page is noindex (a site before launch, under its blanket
1728
- * robots meta), a sitemap listing them is not refused: that disagreement ends with the launch. */
1729
- const sitemapNoindex = {
1730
- id: "sitemap-noindex",
1731
- title: "Published URL lists match the built pages",
1732
- severity: "error",
1733
- stage: "dist",
1734
- begin: (ctx) => {
1735
- if (!ctx.hasDist) return null;
1736
- const start = ctx.has(SITEMAP_INDEX) ? [SITEMAP_INDEX] : ctx.files.filter((f) => /^sitemap[^/]*\.xml$/.test(f));
1737
- if (start.length === 0 && !ctx.has(LLMS)) return null;
1738
- const noindex = /* @__PURE__ */ new Map();
1739
- let indexable = 0;
1740
- return {
1741
- visit: (page) => {
1742
- if (page.redirect) return;
1743
- if (page.noindex) noindex.set(normalize(page.url), page.path);
1744
- else indexable += 1;
1745
- },
1746
- finish: () => {
1747
- const findings = [];
1748
- const sitemaps = new Map(start.map((file) => [file, ""]));
1749
- for (const [sitemap, index] of sitemaps) {
1750
- if (!ctx.has(sitemap)) {
1751
- findings.push({
1752
- path: index,
1753
- message: `The sitemap index names ${sitemap}, which is not in the build.`
1754
- });
1755
- continue;
1756
- }
1757
- const xml = ctx.read(sitemap);
1758
- if (/<sitemapindex\b/i.test(xml)) {
1759
- for (const loc of locs(xml)) {
1760
- const child = toPath(loc).replace(/^\//, "");
1761
- if (!sitemaps.has(child)) sitemaps.set(child, sitemap);
1762
- }
1763
- continue;
1764
- }
1765
- for (const loc of locs(xml)) {
1766
- const urlPath = toPath(loc);
1767
- if (!ctx.serves(urlPath)) findings.push({
1768
- path: sitemap,
1769
- message: `The sitemap lists ${loc}, which is not in the build.`
1770
- });
1771
- else if (indexable > 0 && noindex.has(urlPath)) findings.push({
1772
- path: sitemap,
1773
- message: `The sitemap lists ${loc}, whose page says noindex: the sitemap filter and the noindex routes disagree.`
1774
- });
1775
- }
1776
- }
1777
- if (ctx.has(LLMS)) for (const match of ctx.read(LLMS).matchAll(/\]\(([^)\s]+)\)/g)) {
1778
- const link = match[1];
1779
- if (/^[a-z][a-z0-9+.-]*:/i.test(link) && !ctx.config.site) continue;
1780
- if (/^[a-z][a-z0-9+.-]*:/i.test(link)) {
1781
- let host;
1782
- try {
1783
- host = new URL(link).host;
1784
- } catch {
1785
- continue;
1786
- }
1787
- if (host !== new URL(ctx.config.site).host) continue;
1788
- }
1789
- if (!ctx.serves(toPath(link))) findings.push({
1790
- path: LLMS,
1791
- message: `llms.txt links ${link}, which is not in the build.`
1792
- });
1793
- }
1794
- return findings;
1795
- }
1796
- };
1797
- }
1798
- };
1799
- //#endregion
1800
1832
  //#region src/checks/syncOnce.ts
1801
1833
  const LOADER_FILES = ["src/content.config.ts", "src/content/config.ts"];
1802
1834
  /** A loader written inline, as opposed to `glob()` or `file()`. */
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-CYG52KHL.mjs";
1
+ import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-AmQJK-Qj.mjs";
2
2
  export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, USAGE, blockingResults, checks, checksOf, cli, distChecks, findingLine, loadOptions, readAstroConfig, refusalMessage, runDistChecks, runSiteChecks, runStage, summarizeBlocking, summaryLines };
@@ -4,6 +4,7 @@
4
4
 
5
5
  Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
6
6
 
7
+ - `versions/0.4.2/CHANGELOG.md`: release notes for 0.4.2
7
8
  - `versions/0.4.1/CHANGELOG.md`: release notes for 0.4.1
8
9
  - `versions/0.4.0/CHANGELOG.md`: release notes for 0.4.0
9
10
  - `versions/0.3.3/CHANGELOG.md`: release notes for 0.3.3
@@ -4,6 +4,7 @@
4
4
 
5
5
  Migration guides of `@v-office/site-checks`, newest first. Apply them in order when skipping versions.
6
6
 
7
+ - `versions/0.4.2/MIGRATION.md`: Migration: 0.4.1 to 0.4.2
7
8
  - `versions/0.4.1/MIGRATION.md`: Migration: 0.4.0 to 0.4.1
8
9
  - `versions/0.4.0/MIGRATION.md`: Migration: 0.3.3 to 0.4.0
9
10
  - `versions/0.3.3/MIGRATION.md`: Migration: 0.3.2 to 0.3.3
@@ -0,0 +1,13 @@
1
+ # Changelog: 0.4.2
2
+
3
+ Two warnings that fired on correct pages no longer do.
4
+
5
+ ## Fixed
6
+
7
+ - `page-heads` no longer reports language versions of one page as duplicate titles or
8
+ descriptions: two pages that name each other as `<link rel="alternate" hreflang>` share a title
9
+ without competing, also when the links are absolute on the production host. A page that repeats a
10
+ title without that link both ways is still reported.
11
+ - `page-structure` (`table-headers`) takes `aria-label` or `aria-labelledby` as a table's name, as a
12
+ calendar grid (`<table role="grid" aria-label="November 2026">`) has it; a table with neither
13
+ and no `<caption>` is still reported.
@@ -0,0 +1,11 @@
1
+ # Migration: 0.4.1 to 0.4.2
2
+
3
+ No changes required. Fewer warnings: a table named by `aria-label` or `aria-labelledby` (a date
4
+ picker's grid) needs no `<caption>`, and language versions that name each other as `hreflang`
5
+ alternates may share a title and description. An `exclude` entry a site added for either can go.
6
+
7
+ ## 1. Upgrade
8
+
9
+ ```sh
10
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.4.2
11
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/site-checks",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report, and a site excludes the findings it accepts in site-checks.config.json",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {