chore: auto deploy 2026-01-21 10:39:57
This commit is contained in:
33
build.js
33
build.js
@@ -9,11 +9,20 @@ data.languages.forEach(lang => {
|
|||||||
const content = data.content[lang];
|
const content = data.content[lang];
|
||||||
let html = template;
|
let html = template;
|
||||||
|
|
||||||
|
const fullBasePath = data.siteConfig.basePath;
|
||||||
|
const fullDomain = data.siteConfig.domain;
|
||||||
|
|
||||||
html = html.replace(/{{langCode}}/g, lang);
|
html = html.replace(/{{langCode}}/g, lang);
|
||||||
html = html.replace(/{{title}}/g, content.title);
|
html = html.replace(/{{title}}/g, content.title);
|
||||||
html = html.replace(/{{metaDesc}}/g, content.metaDesc);
|
html = html.replace(/{{metaDesc}}/g, content.metaDesc);
|
||||||
|
|
||||||
// 语言链接 - 动态生成
|
// SEO Dynamic Tags
|
||||||
|
const canonicalUrl = `${fullDomain}${fullBasePath}/${lang}/index.html`;
|
||||||
|
html = html.replace(/{{canonicalUrl}}/g, canonicalUrl);
|
||||||
|
// Use a default OG image or generate one (placeholder for now)
|
||||||
|
html = html.replace(/{{ogImage}}/g, `${fullDomain}${fullBasePath}/assets/og-shared.jpg`);
|
||||||
|
|
||||||
|
// 语言链接 - 动态生成 (保持相对路径,兼容性更好)
|
||||||
const langLinksHtml = data.languages.map(l => {
|
const langLinksHtml = data.languages.map(l => {
|
||||||
const lContent = data.content[l];
|
const lContent = data.content[l];
|
||||||
if (l === lang) return `<span class="active-lang">${lContent.langName}</span>`;
|
if (l === lang) return `<span class="active-lang">${lContent.langName}</span>`;
|
||||||
@@ -64,3 +73,25 @@ data.languages.forEach(lang => {
|
|||||||
fs.writeFileSync(path.join(outputDir, 'index.html'), html);
|
fs.writeFileSync(path.join(outputDir, 'index.html'), html);
|
||||||
console.log(`✅ ${lang} 版生成完毕`);
|
console.log(`✅ ${lang} 版生成完毕`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 生成 sitemap.xml
|
||||||
|
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
${data.languages.map(lang => `
|
||||||
|
<url>
|
||||||
|
<loc>${data.siteConfig.domain}${data.siteConfig.basePath}/${lang}/index.html</loc>
|
||||||
|
<lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
|
||||||
|
<priority>0.80</priority>
|
||||||
|
</url>`).join('')}
|
||||||
|
</urlset>`;
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'dist', 'sitemap.xml'), sitemap);
|
||||||
|
console.log('✅ sitemap.xml 已生成');
|
||||||
|
|
||||||
|
// 生成 robots.txt
|
||||||
|
const robots = `User-agent: *
|
||||||
|
Allow: /
|
||||||
|
|
||||||
|
Sitemap: ${data.siteConfig.domain}${data.siteConfig.basePath}/sitemap.xml
|
||||||
|
`;
|
||||||
|
fs.writeFileSync(path.join(__dirname, 'dist', 'robots.txt'), robots);
|
||||||
|
console.log('✅ robots.txt 已生成');
|
||||||
|
|||||||
4
data.js
4
data.js
@@ -1,6 +1,10 @@
|
|||||||
// data.js - 2026 世界杯 16 城市全量三语数据库
|
// data.js - 2026 世界杯 16 城市全量三语数据库
|
||||||
module.exports = {
|
module.exports = {
|
||||||
languages: ['zh', 'en', 'es'],
|
languages: ['zh', 'en', 'es'],
|
||||||
|
siteConfig: {
|
||||||
|
domain: "https://pickbetterai.com",
|
||||||
|
basePath: "/worldcup-2026",
|
||||||
|
},
|
||||||
content: {
|
content: {
|
||||||
zh: {
|
zh: {
|
||||||
langName: "中文",
|
langName: "中文",
|
||||||
|
|||||||
@@ -6,6 +6,26 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
<meta name="description" content="{{metaDesc}}">
|
<meta name="description" content="{{metaDesc}}">
|
||||||
|
|
||||||
|
<!-- SEO & Canonical -->
|
||||||
|
<link rel="canonical" href="{{canonicalUrl}}">
|
||||||
|
|
||||||
|
<!-- Open Graph / Facebook -->
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:url" content="{{canonicalUrl}}">
|
||||||
|
<meta property="og:title" content="{{title}}">
|
||||||
|
<meta property="og:description" content="{{metaDesc}}">
|
||||||
|
<meta property="og:image" content="{{ogImage}}">
|
||||||
|
|
||||||
|
<!-- Twitter -->
|
||||||
|
<meta property="twitter:card" content="summary_large_image">
|
||||||
|
<meta property="twitter:url" content="{{canonicalUrl}}">
|
||||||
|
<meta property="twitter:title" content="{{title}}">
|
||||||
|
<meta property="twitter:description" content="{{metaDesc}}">
|
||||||
|
<meta property="twitter:image" content="{{ogImage}}">
|
||||||
|
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚽️</text></svg>">
|
||||||
|
|
||||||
<!-- Google Fonts -->
|
<!-- Google Fonts -->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
|||||||
Reference in New Issue
Block a user