feat: 添加百度主动推送脚本,加速 SEO 收录
- 新建 scripts/baidu-push.mjs,推送 32 个页面 URL 到百度 - package.json 添加 pnpm baidu-push 命令 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
这个提交包含在:
父节点
e894f0fb76
当前提交
b82712deed
@ -7,7 +7,8 @@
|
||||
"dev": "nuxt dev",
|
||||
"build": "nuxt build && cp -f .env .output/.env 2>/dev/null || true",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview"
|
||||
"preview": "nuxt preview",
|
||||
"baidu-push": "node scripts/baidu-push.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@css-render/vue3-ssr": "^0.15.14",
|
||||
|
||||
78
scripts/baidu-push.mjs
普通文件
78
scripts/baidu-push.mjs
普通文件
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 百度主动推送脚本
|
||||
* 用法:node scripts/baidu-push.mjs
|
||||
*
|
||||
* 将站点所有页面 URL 推送给百度,加速收录。
|
||||
* 建议每次部署后或内容更新后执行一次。
|
||||
*/
|
||||
|
||||
const SITE = 'https://www.1814.love'
|
||||
const TOKEN = process.env.BAIDU_PUSH_TOKEN || 'xpS22S0bG8VkQ97m'
|
||||
const API = `http://data.zz.baidu.com/urls?site=${SITE}&token=${TOKEN}`
|
||||
|
||||
// 所有需要推送的页面
|
||||
const urls = [
|
||||
'/',
|
||||
'/products',
|
||||
'/products/v9-5d4n-forest',
|
||||
'/products/v9-5d4n-prairie',
|
||||
'/products/v9-6d5n-family',
|
||||
'/products/v9-6d5n-explore',
|
||||
'/products/v9-7d6n-family',
|
||||
'/products/v9-7d6n-wild',
|
||||
'/products/autumn',
|
||||
'/products/winter',
|
||||
'/summer-camp',
|
||||
'/winter-camp',
|
||||
'/courses',
|
||||
'/pricing',
|
||||
'/selector',
|
||||
'/faq',
|
||||
'/reviews',
|
||||
'/blog',
|
||||
'/news',
|
||||
'/stories',
|
||||
'/gallery',
|
||||
'/destinations',
|
||||
'/calendar',
|
||||
'/guides',
|
||||
'/guide-custom',
|
||||
'/about',
|
||||
'/contact',
|
||||
'/customize',
|
||||
'/qualifications',
|
||||
'/partners',
|
||||
'/xiaohongshu',
|
||||
'/youji',
|
||||
]
|
||||
|
||||
const body = urls.map(u => `${SITE}${u}`).join('\n')
|
||||
|
||||
console.log(`推送 ${urls.length} 个 URL 到百度...`)
|
||||
|
||||
try {
|
||||
const res = await fetch(API, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
body,
|
||||
})
|
||||
const data = await res.json()
|
||||
|
||||
if (data.success) {
|
||||
console.log(`✅ 成功推送 ${data.success} 个,今日剩余配额 ${data.remain}`)
|
||||
} else if (data.error) {
|
||||
console.error(`❌ 推送失败: ${data.message} (${data.error})`)
|
||||
} else {
|
||||
console.log('响应:', JSON.stringify(data, null, 2))
|
||||
}
|
||||
|
||||
if (data.not_same_site?.length) {
|
||||
console.log('⚠️ 以下 URL 不属于该站点:', data.not_same_site)
|
||||
}
|
||||
if (data.not_valid?.length) {
|
||||
console.log('⚠️ 以下 URL 格式不合法:', data.not_valid)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('❌ 请求失败:', err.message)
|
||||
}
|
||||
正在加载...
x
在新工单中引用
屏蔽一个用户