62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
|
|
import { injectRobotsNoindex, injectSeoTags } from './mindspace-seo-tags.mjs';
|
||
|
|
import { injectGeoTags } from './mindspace-geo-tags.mjs';
|
||
|
|
import { buildMindspaceGeoPayload, upsertDescriptionMeta, upsertMindspaceGeoMeta } from './mindspace-geo-backfill.mjs';
|
||
|
|
import { injectOgTags, PLATFORM_SITE_NAME } from './mindspace-og-tags.mjs';
|
||
|
|
|
||
|
|
export function renderMindspaceGeoMetaTag(payload) {
|
||
|
|
return `<meta name="mindspace-geo" content='${JSON.stringify(payload).replace(/'/g, ''')}'> `;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function decoratePlatformSeoGeoHtml(
|
||
|
|
html,
|
||
|
|
{
|
||
|
|
origin = '',
|
||
|
|
pageUrl = '',
|
||
|
|
pageDirUrl = '',
|
||
|
|
canonicalEnabled = true,
|
||
|
|
jsonLdEnabled = true,
|
||
|
|
noindex = false,
|
||
|
|
meta = {},
|
||
|
|
} = {},
|
||
|
|
) {
|
||
|
|
const source = String(html ?? '');
|
||
|
|
let next = upsertDescriptionMeta(source, meta.description ?? buildMindspaceGeoPayload(source).summary);
|
||
|
|
next = upsertMindspaceGeoMeta(next, meta.geo ?? buildMindspaceGeoPayload(next));
|
||
|
|
next = injectOgTags(next, {
|
||
|
|
origin,
|
||
|
|
pageUrl,
|
||
|
|
pageDirUrl,
|
||
|
|
siteName: meta.siteName ?? PLATFORM_SITE_NAME,
|
||
|
|
meta,
|
||
|
|
});
|
||
|
|
next = injectSeoTags(next, {
|
||
|
|
origin,
|
||
|
|
pageUrl,
|
||
|
|
pageDirUrl,
|
||
|
|
canonicalEnabled,
|
||
|
|
meta,
|
||
|
|
});
|
||
|
|
if (jsonLdEnabled) {
|
||
|
|
next = injectGeoTags(next, {
|
||
|
|
origin,
|
||
|
|
pageUrl,
|
||
|
|
pageDirUrl,
|
||
|
|
sourceHtml: next,
|
||
|
|
meta,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if (noindex) {
|
||
|
|
next = injectRobotsNoindex(next);
|
||
|
|
}
|
||
|
|
return next;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const PLATFORM_STATIC_DISCOVERY_ENTRIES = [
|
||
|
|
{
|
||
|
|
publicUrl: '/learn/',
|
||
|
|
title: '我的学习小助手',
|
||
|
|
summary: 'TKMind 儿童学习打卡与习惯养成助手,支持任务清单、成长记录与家长协同。',
|
||
|
|
updatedAt: Date.parse('2026-09-16T00:00:00.000Z'),
|
||
|
|
},
|
||
|
|
];
|