File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 1
1
// 封装异步加载资源的方法
2
2
import { memo } from 'react'
3
+ import BLOG from '@/blog.config'
4
+
5
+ /**
6
+ * 判断是否是Vercel生产环境,主要为了避免写入文件
7
+ * @type {boolean }
8
+ */
9
+ export const isNotVercelProduction =
10
+ process . env . npm_lifecycle_event === 'build' ||
11
+ process . env . npm_lifecycle_event === 'export' ||
12
+ ! BLOG [ 'isProd' ]
13
+
3
14
4
15
/**
5
16
* 判断是否客户端
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import { getGlobalData, getPostBlocks } from '@/lib/db/getSiteData'
4
4
import { generateRobotsTxt } from '@/lib/robots.txt'
5
5
import { generateSitemapXml } from '@/lib/sitemap.xml'
6
6
import { DynamicLayout } from '@/themes/theme'
7
+ import { isNotVercelProduction } from '@/lib/utils'
8
+ import { generateRss } from '@/lib/rss'
7
9
8
10
/**
9
11
* 首页布局
@@ -53,12 +55,14 @@ export async function getStaticProps(req) {
53
55
}
54
56
}
55
57
56
- // 生成robotTxt
57
- generateRobotsTxt ( props )
58
- // 生成Feed订阅
59
- // generateRss(props)
60
- // 生成
61
- generateSitemapXml ( props )
58
+ if ( isNotVercelProduction ) {
59
+ // 生成robotTxt
60
+ generateRobotsTxt ( props )
61
+ // 生成Feed订阅
62
+ generateRss ( props )
63
+ // 生成
64
+ generateSitemapXml ( props )
65
+ }
62
66
63
67
// 生成全文索引 - 仅在 yarn build 时执行 && process.env.npm_lifecycle_event === 'build'
64
68
You can’t perform that action at this time.
0 commit comments