diff --git a/assets/og-shared.jpg b/assets/og-shared.jpg new file mode 100644 index 0000000..7c54480 Binary files /dev/null and b/assets/og-shared.jpg differ diff --git a/build.js b/build.js index 753bffc..3a551ec 100644 --- a/build.js +++ b/build.js @@ -5,6 +5,28 @@ const data = require('./data.js'); const template = fs.readFileSync(path.join(__dirname, 'template.html'), 'utf-8'); +// 清理并创建 dist 目录 +const distDir = path.join(__dirname, 'dist'); +if (fs.existsSync(distDir)) { + fs.rmSync(distDir, { recursive: true, force: true }); +} +fs.mkdirSync(distDir); + +// 创建子目录 +const projectSubDir = path.join(distDir, data.siteConfig.basePath.replace(/^\//, '')); +if (!fs.existsSync(projectSubDir)) { + fs.mkdirSync(projectSubDir, { recursive: true }); +} + +// 拷贝 assets 目录 +const assetsDir = path.join(__dirname, 'assets'); +const targetAssetsDir = path.join(projectSubDir, 'assets'); +if (fs.existsSync(assetsDir)) { + if (!fs.existsSync(targetAssetsDir)) fs.mkdirSync(targetAssetsDir, { recursive: true }); + fs.cpSync(assetsDir, targetAssetsDir, { recursive: true }); + console.log('✅ Assets 已同步'); +} + data.languages.forEach(lang => { const content = data.content[lang]; let html = template; @@ -66,12 +88,10 @@ data.languages.forEach(lang => { html = html.replace(/{{tableRows}}/g, rowsHtml); - const distDir = path.join(__dirname, 'dist'); - const outputDir = path.join(distDir, lang); - if (!fs.existsSync(distDir)) fs.mkdirSync(distDir); - if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir); + const outputDir = path.join(projectSubDir, lang); + if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true }); fs.writeFileSync(path.join(outputDir, 'index.html'), html); - console.log(`✅ ${lang} 版生成完毕`); + console.log(`✅ ${lang} 版生成完毕 (输出至: ${data.siteConfig.basePath}/${lang}/)`); }); // 生成 sitemap.xml @@ -95,3 +115,116 @@ Sitemap: ${data.siteConfig.domain}${data.siteConfig.basePath}/sitemap.xml `; fs.writeFileSync(path.join(__dirname, 'dist', 'robots.txt'), robots); console.log('✅ robots.txt 已生成'); + +// 生成根目录首页 (PickBetterAI.com 门面) +const homeHtml = ` + + + + + Pick Better AI - Smart Decisions Enhanced by AI + + + + +
+
+
PickBetterAI
+

Smart Decisions, Enhanced by AI

+

We help you find the best options in travel, tech, and life.

+
+ +
+ +
Active Tool
+
⚽️
+
+

2026 World Cup City Planner

+

Compare 16 host cities across USA, Canada, and Mexico. Decide where to watch based on match count, budget, and local logistics. Multi-language support included.

+
+
+ +
+
Coming Soon
+
💻
+

AI Tech Selection

+

Picking the right AI model or tool for your specific workflow.

+
+ +
+
Coming Soon
+
✈️
+

Smart Travel

+

Data-driven destination comparison for digital nomads.

+
+ +
+

© 2026 PickBetterAI.com | All Rights Reserved

+
+
+
+ +`; + +fs.writeFileSync(path.join(__dirname, 'dist', 'index.html'), homeHtml); +console.log('✅ 根目录首页 index.html 已生成');