Skip to content

Commit d6246d5

Browse files
author
微信公众号:储凡
authored
Merge pull request #155 from 142vip/feat/add-site
feat(@142vip/utils): 新增`getDocSiteBase`方法
2 parents e55cb01 + 171f32a commit d6246d5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/utils/src/constants.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
/**
23
* 一些地址信息
34
*/
@@ -29,3 +30,15 @@ export const OPEN_SOURCE_AUTHOR = {
2930
githubVip: 'https://github.com/142vip',
3031
gitee: 'https://gitee.com/chufan443',
3132
}
33+
34+
/**
35+
* 用于区分base路径,是否nginx代理
36+
* - 路径名称
37+
* - 环境变量 NEED_PROXY
38+
* @param baseName
39+
*/
40+
export function getDocSiteBase(baseName: string): '/' | `/${string}/` {
41+
const needProxy = process.env.NEED_PROXY ?? false
42+
43+
return needProxy ? `/${baseName}/` : '/'
44+
}

0 commit comments

Comments
 (0)