主题配置文件Notion化

This commit is contained in:
tangly1024.com
2023-11-07 14:52:21 +08:00
parent e084053098
commit f2e2ae8d5f
118 changed files with 570 additions and 528 deletions

View File

@@ -8,12 +8,13 @@ import { deepClone } from './utils'
* 读取配置
* 1. 优先读取NotionConfig表
* 2. 其次读取环境变量
* 3. 再读取blog.config.js文件
* 3. 再读取blog.config.js / 或各个主题的CONFIG文件
* @param {*} key 参数名
* @param {*} defaultVal ; 参数不存在默认返回值
* @param {*} extendConfig ; 参考配置对象{key:val}如果notion中找不到优先尝试在这里面查找
* @returns
*/
export const siteConfig = (key, defaultVal = null) => {
export const siteConfig = (key, defaultVal = null, extendConfig) => {
let global = null
try {
// eslint-disable-next-line react-hooks/rules-of-hooks
@@ -45,6 +46,11 @@ export const siteConfig = (key, defaultVal = null) => {
}
}
// 其次 有传入的配置参考,则尝试读取
if (!extendConfig) {
val = extendConfig[key]
}
// 其次 NOTION没有找到配置则会读取blog.config.js文件
if (!val) {
val = BLOG[key]