fde6503bdf
Memind CI / Test, build, and release guards (push) Has been cancelled
Enable optional SEO/GEO injection and discovery routes for confirmed public pages while keeping private pages noindex. Add premium page template skills, portal catalog API, template shop UI, and Baidu push gated by memind_adm config. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
injectRobotsNoindex,
|
|
injectSeoTags,
|
|
resolveCanonicalUrl,
|
|
} from './mindspace-seo-tags.mjs';
|
|
|
|
test('injectRobotsNoindex adds robots meta tags once', () => {
|
|
const html = '<html><head><title>Demo</title></head><body></body></html>';
|
|
const next = injectRobotsNoindex(html);
|
|
assert.match(next, /name="robots" content="noindex, nofollow"/);
|
|
assert.match(next, /name="googlebot" content="noindex, nofollow"/);
|
|
assert.equal(injectRobotsNoindex(next), next);
|
|
});
|
|
|
|
test('injectSeoTags adds canonical and description', () => {
|
|
const html = '<html><head><title>Demo</title></head><body><h1>Hi</h1></body></html>';
|
|
const next = injectSeoTags(html, {
|
|
origin: 'https://m.tkmind.cn',
|
|
pageUrl: 'https://m.tkmind.cn/u/john/pages/demo',
|
|
publication: { publicUrl: '/u/john/pages/demo' },
|
|
canonicalEnabled: true,
|
|
});
|
|
assert.match(next, /rel="canonical" href="https:\/\/m\.tkmind\.cn\/u\/john\/pages\/demo"/);
|
|
});
|
|
|
|
test('resolveCanonicalUrl prefers publication public url', () => {
|
|
assert.equal(
|
|
resolveCanonicalUrl({
|
|
publication: { publicUrl: '/u/john/pages/demo' },
|
|
origin: 'https://m.tkmind.cn',
|
|
}),
|
|
'https://m.tkmind.cn/u/john/pages/demo',
|
|
);
|
|
});
|