feat(mindspace): add SEO/GEO delivery, page template catalog, and admin hooks
Memind CI / Test, build, and release guards (push) Has been cancelled
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>
This commit is contained in:
@@ -26,6 +26,7 @@ function parseArgs(argv) {
|
||||
let root = path.join(repoRoot, DEFAULT_PUBLISH_ROOT);
|
||||
let userId = null;
|
||||
let file = null;
|
||||
let seo = false;
|
||||
for (let i = 2; i < argv.length; i += 1) {
|
||||
if (argv[i] === '--root' && argv[i + 1]) {
|
||||
root = path.resolve(argv[i + 1]);
|
||||
@@ -36,12 +37,14 @@ function parseArgs(argv) {
|
||||
} else if (argv[i] === '--file' && argv[i + 1]) {
|
||||
file = path.resolve(argv[i + 1]);
|
||||
i += 1;
|
||||
} else if (argv[i] === '--seo') {
|
||||
seo = true;
|
||||
} else if (argv[i] === '--help' || argv[i] === '-h') {
|
||||
console.log(`Usage: node scripts/check-mindspace-cover.mjs [--root ${DEFAULT_PUBLISH_ROOT}] [--user <uuid>] [--file <html>]`);
|
||||
console.log(`Usage: node scripts/check-mindspace-cover.mjs [--root ${DEFAULT_PUBLISH_ROOT}] [--user <uuid>] [--file <html>] [--seo]`);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
return { root, userId, file };
|
||||
return { root, userId, file, seo };
|
||||
}
|
||||
|
||||
function hasCoverImageHint(html) {
|
||||
@@ -106,6 +109,23 @@ function auditCoverHtml(htmlPath, html) {
|
||||
return issues;
|
||||
}
|
||||
|
||||
function auditSeoHtml(html) {
|
||||
const issues = [];
|
||||
const title = String(html).match(/<title[^>]*>([^<]+)<\/title>/i)?.[1]?.replace(/\s+/g, ' ').trim() ?? '';
|
||||
if (!title || title.length < 4) {
|
||||
issues.push({ level: 'warn', code: 'weak_title', message: '缺少或过短的 <title>,SEO/GEO 质量会下降' });
|
||||
} else if (/^(页面|我的页面|未命名|demo|test|MindSpace 页面)$/i.test(title)) {
|
||||
issues.push({ level: 'warn', code: 'generic_title', message: `title 过于泛化:${title}` });
|
||||
}
|
||||
if (!/<h1\b/i.test(html)) {
|
||||
issues.push({ level: 'warn', code: 'missing_h1', message: '缺少 <h1>,搜索引擎与 AI 抽取质量会下降' });
|
||||
}
|
||||
if (!hasShareDescription(html)) {
|
||||
issues.push({ level: 'warn', code: 'seo_missing_description', message: '缺少 description,SEO/GEO 摘要来源不足' });
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
function collectHtmlFiles(root, userId) {
|
||||
const files = [];
|
||||
const walk = (dir) => {
|
||||
@@ -135,13 +155,14 @@ function collectHtmlFiles(root, userId) {
|
||||
return files;
|
||||
}
|
||||
|
||||
const { root, userId, file } = parseArgs(process.argv);
|
||||
const { root, userId, file, seo } = parseArgs(process.argv);
|
||||
const targets = file ? [file] : collectHtmlFiles(root, userId);
|
||||
const results = [];
|
||||
|
||||
for (const htmlPath of targets) {
|
||||
const html = fs.readFileSync(htmlPath, 'utf8');
|
||||
const issues = auditCoverHtml(htmlPath, html);
|
||||
if (seo) issues.push(...auditSeoHtml(html));
|
||||
if (issues.length) {
|
||||
results.push({ htmlPath, issues });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user