mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
26 lines
602 B
JavaScript
26 lines
602 B
JavaScript
import fs from 'fs'
|
||
import { siteConfig } from './config'
|
||
|
||
export async function generateRobotsTxt(NOTION_CONFIG) {
|
||
const LINK = siteConfig('LINK', '', NOTION_CONFIG)
|
||
const content = `
|
||
# *
|
||
User-agent: *
|
||
Allow: /
|
||
|
||
# Host
|
||
Host: ${LINK}
|
||
|
||
# Sitemaps
|
||
Sitemap: ${LINK}/sitemap.xml
|
||
|
||
`
|
||
try {
|
||
fs.mkdirSync('./public', { recursive: true })
|
||
fs.writeFileSync('./public/robots.txt', content)
|
||
} catch (error) {
|
||
// 在vercel运行环境是只读的,这里会报错;
|
||
// 但在vercel编译阶段、或VPS等其他平台这行代码会成功执行
|
||
}
|
||
}
|