mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
Merge pull request #2995 from tangly1024/fix/theme-starter-config
配置文件读取规则
This commit is contained in:
@@ -18,6 +18,8 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
|
||||
if (!key) {
|
||||
return null
|
||||
}
|
||||
const getValue = (value, fallback) => (hasVal(value) ? value : fallback)
|
||||
const hasVal = value => value !== undefined && value !== null
|
||||
|
||||
// 特殊配置处理;以下配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
|
||||
switch (key) {
|
||||
@@ -35,7 +37,9 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
|
||||
case 'IS_TAG_COLOR_DISTINGUISHED':
|
||||
case 'TAG_SORT_BY_COUNT':
|
||||
case 'LINK':
|
||||
return convertVal(extendConfig[key] || defaultVal || BLOG[key])
|
||||
return convertVal(
|
||||
getValue(extendConfig[key], getValue(defaultVal, BLOG[key]))
|
||||
)
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -79,16 +83,16 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
|
||||
}
|
||||
|
||||
// 其次 有传入的extendConfig,则尝试读取
|
||||
if (!val && extendConfig) {
|
||||
if (!hasVal(val) && extendConfig) {
|
||||
val = extendConfig[key]
|
||||
}
|
||||
|
||||
// 其次 NOTION没有找到配置,则会读取blog.config.js文件
|
||||
if (!val) {
|
||||
if (!hasVal(val)) {
|
||||
val = BLOG[key]
|
||||
}
|
||||
|
||||
if (!val) {
|
||||
if (!hasVal(val)) {
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user