mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 23:16:50 +00:00
fix/file-write
This commit is contained in:
@@ -3,17 +3,22 @@ import fs from 'fs'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
export async function generateRobotsTxt() {
|
||||
fs.mkdirSync('./public', { recursive: true })
|
||||
fs.writeFileSync('./public/robots.txt', `
|
||||
# *
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
# Host
|
||||
Host: ${BLOG.LINK}
|
||||
|
||||
# Sitemaps
|
||||
Sitemap: ${BLOG.LINK}/sitemap.xml
|
||||
|
||||
`)
|
||||
const content = `
|
||||
# *
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
# Host
|
||||
Host: ${BLOG.LINK}
|
||||
|
||||
# Sitemaps
|
||||
Sitemap: ${BLOG.LINK}/sitemap.xml
|
||||
|
||||
`
|
||||
try {
|
||||
fs.writeFileSync('robots.txt', content)
|
||||
fs.writeFileSync('./public/robots.txt', content)
|
||||
} catch (error) {
|
||||
console.warn('无法写入文件', error)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user