Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ gsc-coverage-report.csv
.seo-fix-backup-path

service_account.json
dist_large/
7 changes: 4 additions & 3 deletions seo-audit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// seo-audit.mjs β€” machine-check every built page in dist/.
// Run after `npm run build`. Exits 1 if any ERROR found (CI-safe).
import { readdirSync, readFileSync, existsSync, statSync } from 'node:fs';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';

const DIST = 'dist';
Expand Down Expand Up @@ -68,9 +69,9 @@ const titles = new Map();
const descs = new Map();
const NOINDEX_OK = [/^\/404(\.html)?\/?$/, /^\/sitemap-page\/$/, /^\/embed\//];

for (const f of htmlFiles) {
await Promise.all(htmlFiles.map(async (f) => {
const page = f.slice(DIST.length).replace(/index\.html$/, '') || '/';
const html = readFileSync(f, 'utf8');
const html = await readFile(f, 'utf8');
const isNoindexOk = NOINDEX_OK.some((r) => r.test(page)) || page === '/404.html/';

// canonical
Expand Down Expand Up @@ -132,7 +133,7 @@ for (const f of htmlFiles) {
else if (r === 'needs-slash') warn(`${page} β€” link ${h} missing trailing slash (301 hop)`);
else if (r === 'redirect' && !h.startsWith('/go/')) warn(`${page} β€” link ${h} goes through a 301 (point it at the target directly)`);
}
}
}));

// duplicates
for (const [t, pages] of titles) if (pages.length > 1) warn(`DUPLICATE TITLE on ${pages.join(' , ')} :: "${t.slice(0, 70)}"`);
Expand Down