部分参数配置化

This commit is contained in:
tangly1024.com
2023-11-03 17:10:59 +08:00
parent 545c071f81
commit f145d8b28c
23 changed files with 267 additions and 208 deletions

View File

@@ -9,10 +9,11 @@ import { deepClone } from './utils'
* 1. 优先读取NotionConfig表
* 2. 其次读取环境变量
* 3. 再读取blog.config.js文件
* @param {*} key
* @param {*} key 参数名
* @param {*} defaultVal ; 参数不存在默认返回值
* @returns
*/
export const siteConfig = (key) => {
export const siteConfig = (key, defaultVal = null) => {
let global = null
try {
// eslint-disable-next-line react-hooks/rules-of-hooks
@@ -36,7 +37,7 @@ export const siteConfig = (key) => {
val = siteInfo?.pageCover // 封面图取Notion的封面
break
case 'AVATAR':
val = siteInfo?.icon // 封面图取Notion的封面
val = siteInfo?.icon // 封面图取Notion的头像
break
case 'TITLE':
val = siteInfo?.title // 标题取Notion中的标题
@@ -48,7 +49,10 @@ export const siteConfig = (key) => {
if (!val) {
val = BLOG[key]
}
console.log('实际配置', key, val)
if (!val) {
val = defaultVal
}
// console.log('实际配置', key, val)
return val
}