mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 08:12:54 -07:00
b68d17614d
- 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
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import type { TransformContext } from 'vitepress';
|
|
import docsConfig from './.vitepress/config';
|
|
|
|
function makeTransformContext(page: string): TransformContext {
|
|
return {
|
|
page,
|
|
siteConfig: {} as TransformContext['siteConfig'],
|
|
siteData: {} as TransformContext['siteData'],
|
|
pageData: {} as TransformContext['pageData'],
|
|
title: 'SubMiner',
|
|
description: 'SubMiner docs',
|
|
head: [],
|
|
content: '',
|
|
assets: [],
|
|
};
|
|
}
|
|
|
|
test('docs pages emit stable self-referential canonical URLs', async () => {
|
|
const rootHead = await docsConfig.transformHead?.(makeTransformContext('index.md'));
|
|
const usageHead = await docsConfig.transformHead?.(makeTransformContext('usage.md'));
|
|
|
|
expect(rootHead).toContainEqual([
|
|
'link',
|
|
{ rel: 'canonical', href: 'https://docs.subminer.moe/' },
|
|
]);
|
|
expect(usageHead).toContainEqual([
|
|
'link',
|
|
{ rel: 'canonical', href: 'https://docs.subminer.moe/usage' },
|
|
]);
|
|
expect(JSON.stringify(rootHead).toLowerCase()).not.toContain('noindex');
|
|
});
|
|
|
|
test('docs sitemap excludes duplicate README page from indexable URLs', async () => {
|
|
const items = [{ url: '' }, { url: 'README' }, { url: 'usage' }];
|
|
|
|
const transformedItems = await docsConfig.sitemap?.transformItems?.(items);
|
|
|
|
expect(transformedItems?.map((item) => item.url)).toEqual(['', 'usage']);
|
|
});
|