Add canonical URLs and sitemap dedup for docs homepage indexability

- Emit self-referential canonical `<link>` tags on every VitePress page
- Filter duplicate /README entry from generated sitemap
- Extract DOCS_HOSTNAME constant; update Plausible test to match
- Add seo.test.ts covering canonical generation and sitemap filtering
This commit is contained in:
2026-05-10 22:19:21 -07:00
parent 30712738dc
commit b68d17614d
6 changed files with 125 additions and 3 deletions
+24 -1
View File
@@ -1,3 +1,15 @@
const DOCS_HOSTNAME = 'https://docs.subminer.moe';
function pageToCanonicalHref(page: string): string | null {
if (page === '404.md') return null;
const route = page
.replace(/(^|\/)index\.md$/, '')
.replace(/\.md$/, '')
.replace(/\/$/, '');
return route ? `${DOCS_HOSTNAME}/${route}` : `${DOCS_HOSTNAME}/`;
}
export default {
title: 'SubMiner Docs',
description:
@@ -34,7 +46,18 @@ export default {
appearance: 'dark',
cleanUrls: true,
metaChunk: true,
sitemap: { hostname: 'https://docs.subminer.moe' },
sitemap: {
hostname: DOCS_HOSTNAME,
transformItems(items) {
return items.filter(
(item) => item.url !== 'README' && item.url !== `${DOCS_HOSTNAME}/README`,
);
},
},
transformHead({ page }) {
const href = pageToCanonicalHref(page);
return href ? [['link', { rel: 'canonical', href }]] : [];
},
lastUpdated: true,
srcExclude: ['subagents/**'],
markdown: {