Files
zacfrontuser_v2/server/generate-seo-templates.cjs

243 lines
10 KiB
JavaScript
Raw Permalink Normal View History

2026-02-28 16:10:29 +08:00
/**
* SEO模板生成器
* 根据路由配置自动生成静态HTML模板
*/
const fs = require('fs')
const path = require('path')
// 页面SEO配置与useSEO.js保持一致
const pageSEOConfigs = {
'index.html': {
title: '真爱查官网_婚姻状态核验_婚前背景互信平台',
description: '真爱查致力于维护婚姻家庭安全。提供基于合法公开数据的婚姻状态报告与综合风险检测。核心排查历史婚姻涉诉记录、失信记录及潜在情感隐患。拒绝盲目信任,一键生成婚恋状态评估,为爱护航。',
keywords: '真爱查, 婚姻状态查询, 婚姻历史核验, 再婚背景调查, 情感风险评估, 婚恋互信工具',
url: 'https://www.zhenaicha.com'
},
'agent.html': {
title: '真爱查代理 - 免费开通代理权限 | 大数据风险报告代理',
description: '真爱查代理平台,免费开通代理权限,享受大数据风险报告查询服务代理收益。专业的大数据风险报告、婚姻查询、个人信用评估等服务的代理合作。',
keywords: '真爱查代理, 免费代理, 大数据风险报告代理, 代理权限, 代理收益',
url: 'https://www.zhenaicha.com/agent'
},
'help.html': {
title: '帮助中心 - 真爱查使用指南 | 常见问题解答',
description: '真爱查帮助中心,提供详细的使用指南、常见问题解答、操作教程等,帮助用户更好地使用大数据风险报告查询服务。',
keywords: '真爱查帮助, 使用指南, 常见问题, 操作教程, 客服支持',
url: 'https://www.zhenaicha.com/help'
},
'help-guide.html': {
title: '使用指南 - 真爱查操作教程 | 功能说明',
description: '真爱查详细使用指南,包含各功能模块的操作教程、功能说明、注意事项等,让用户快速上手使用。',
keywords: '使用指南, 操作教程, 功能说明, 快速上手, 真爱查教程',
url: 'https://www.zhenaicha.com/help/guide'
},
'example.html': {
title: '示例报告 - 真爱查报告展示 | 大数据风险报告样例',
description: '真爱查示例报告展示,包含大数据风险报告、婚姻状况查询、个人信用评估等服务的报告样例,让用户了解报告内容和格式。',
keywords: '示例报告, 报告展示, 报告样例, 大数据风险报告, 婚姻查询报告',
url: 'https://www.zhenaicha.com/example'
},
'service.html': {
title: '客服中心 - 真爱查在线客服 | 技术支持',
description: '真爱查客服中心,提供在线客服支持、技术咨询、问题反馈等服务,确保用户获得及时有效的帮助。',
keywords: '客服中心, 在线客服, 技术支持, 问题反馈, 真爱查客服',
url: 'https://www.zhenaicha.com/service'
},
'inquire-riskassessment.html': {
title: '个人综合履约能力画像_多维风险指数检测_信用健康度_真爱查',
description: '深度解析个人履约能力综合状况,辅助用户进行风险自查。报告维度包含历史履约趋势、多维生活经营风险指数及关联负面标签。数据客观中立,实时更新,帮助用户优化个人资信档案,提升生活经营能力。',
keywords: '个人风险画像,履约能力评估,综合风险指数,信用健康体检,个人数据分析',
url: 'https://www.zhenaicha.com/inquire/riskassessment'
},
'inquire-companyinfo.html': {
title: '商业背景真实性核验_企业主经营实力与司法风险_真爱查',
description: '真爱查企业版助您鉴别商业背景的真实性。一键核验目标对象的名下关联企业、工商变更记录、司法被执行信息及股权冻结状况。全方位评估经营实力与法律风险,规避商业合作或家庭资产联保隐患。',
keywords: '商业背景核验,企业主信用评估,公司经营风险,工商信息核验,资产风险评估',
url: 'https://www.zhenaicha.com/inquire/companyinfo'
},
'inquire-marriage.html': {
title: '婚前综合背景了解_涉婚司法风险评估_情感诚意度报告_真爱查',
description: '真爱查婚恋报告基于公开司法大数据,提供客观的婚前背景参考。深度评估对象的涉婚法律诉讼、失信被执行历史及社会不良标签。旨在消除信息不对称,辅助用户建立透明、安全的婚姻基础。',
keywords: '婚前背景核验,恋爱对象风险,婚姻司法记录,情感互信报告,家庭履约风险',
url: 'https://www.zhenaicha.com/inquire/marriage'
},
'promote.html': {
title: '真爱查合作伙伴计划_婚恋行业数字化风控解决方案_渠道招募',
description: '真爱查开放全国渠道合作,为婚介机构及情感咨询师提供专业的数据化风控工具。一键接入婚恋风险评估系统,支持推广海报生成与多级数据管理。正规项目,赋能合作伙伴,共同挖掘婚恋市场的合规商业价值。',
keywords: '婚恋行业合作,情感咨询工具,风控系统代理,渠道合作伙伴,婚介数据服务',
url: 'https://www.zhenaicha.com/promote'
}
}
/**
* 规范化文案移除损坏字符U+FFFD统一为中文标点避免乱码
*/
function normalizeText(str) {
if (typeof str !== 'string') return str
return str
.replace(/\uFFFD/g, '') // 移除 UTF-8 替换符(乱码)
.replace(/。/g, '。')
.replace(/、/g, '、')
}
/**
* 生成HTML模板
*/
function generateHTMLTemplate(config) {
const title = normalizeText(config.title)
const description = normalizeText(config.description)
const keywords = normalizeText(config.keywords)
const structuredData = {
"@context": "https://schema.org",
"@type": "WebPage",
"name": title,
"description": description,
"url": config.url,
"mainEntity": {
"@type": "Organization",
"name": "真爱查",
"url": "https://www.zhenaicha.com/",
"description": "专业大数据风险报告查询与代理平台,支持个人和企业多场景风控应用"
}
}
return `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 页面标题 -->
<title>${title}</title>
<!-- SEO Meta标签 -->
<meta name="description" content="${description}">
<meta name="keywords" content="${keywords}">
<!-- Open Graph标签 -->
<meta property="og:title" content="${title}">
<meta property="og:description" content="${description}">
<meta property="og:url" content="${config.url}">
<meta property="og:type" content="website">
<meta property="og:site_name" content="真爱查">
<meta property="og:locale" content="zh_CN">
<!-- Twitter Cards -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="${title}">
<meta name="twitter:description" content="${description}">
<meta name="twitter:url" content="${config.url}">
<!-- Canonical URL -->
<link rel="canonical" href="${config.url}">
<!-- 结构化数据 -->
<script type="application/ld+json">
${JSON.stringify(structuredData, null, 8)}
</script>
<!-- 其他Meta标签 -->
<meta name="robots" content="index, follow">
<meta name="googlebot" content="index, follow">
<meta name="baiduspider" content="index, follow">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
margin: 0;
padding: 0;
line-height: 1.6;
}
.seo-content {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h1 { color: #333; }
p { color: #666; }
.redirect-notice {
background: #fff3cd;
border: 1px solid #ffc107;
color: #856404;
padding: 10px;
margin: 20px 0;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="seo-content">
<h1>${title}</h1>
<div class="redirect-notice">
<p>正在跳转到完整版网站...</p>
<p>如果浏览器没有自动跳转 <a href="${config.url}">点击这里</a></p>
</div>
<p>${description}</p>
<!-- 这里可以添加更多SEO友好的静态内容 -->
<section>
<h2>关于真爱查</h2>
<p>真爱查是专业的婚姻状态核验与婚前背景互信平台提供全方位的风险查询服务我们的核心使命是帮助用户建立安全可信赖的婚姻基础</p>
</section>
<section>
<h2>核心服务</h2>
<ul>
<li>个人综合履约能力画像</li>
<li>商业背景真实性核验</li>
<li>婚前综合背景了解</li>
<li>涉婚司法风险评估</li>
<li>情感诚意度报告</li>
</ul>
</section>
<section>
<h2>为什么选择真爱查</h2>
<p>真爱查依托大数据技术为用户提供准确及时的婚恋风险评估报告帮助您做出明智决策</p>
</section>
</div>
<script>
// 可选自动跳转到SPA应用
// setTimeout(function() {
// window.location.href = '${config.url}';
// }, 2000);
</script>
</body>
</html>`
}
/**
* 主函数
*/
function main() {
const outputDir = path.join(__dirname, '../public/seo-templates')
// 创建输出目录
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true })
console.log(`✓ 创建模板目录: ${outputDir}`)
}
// 生成所有模板文件
let successCount = 0
Object.entries(pageSEOConfigs).forEach(([filename, config]) => {
const htmlContent = generateHTMLTemplate(config)
const filePath = path.join(outputDir, filename)
fs.writeFileSync(filePath, htmlContent, 'utf-8')
console.log(`✓ 生成模板: ${filename}`)
successCount++
})
console.log(`\n✓ 成功生成 ${successCount} 个SEO模板文件`)
console.log(`📁 模板目录: ${outputDir}`)
}
// 执行生成
main()