Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 20, 2024
2 parents cf4c015 + 6ac88c9 commit 5be6d0b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
16 changes: 12 additions & 4 deletions components/ExternalPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { isBrowser, loadExternalResource } from '@/lib/utils'
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import Coze from './Coze'
import { GlobalStyle } from './GlobalStyle'
import { initGoogleAdsense } from './GoogleAdsense'
import LA51 from './LA51'
import TianLiGPT from './TianliGPT'

import WebWhiz from './Webwhiz'

/**
Expand Down Expand Up @@ -148,7 +146,7 @@ const ExternalPlugin = props => {
{!CAN_COPY && <DisableCopy />}
{WEB_WHIZ_ENABLED && <WebWhiz />}
{AD_WWADS_BLOCK_DETECT && <AdBlockDetect />}
{TIANLI_KEY && <TianLiGPT />}
{TIANLI_KEY && <TianliGPT />}
<VConsole />
{ENABLE_NPROGRSS && <LoadingProgress />}
<AosAnimation />
Expand Down Expand Up @@ -427,4 +425,14 @@ const AosAnimation = dynamic(() => import('@/components/AOSAnimation'), {
ssr: false
})

const Coze = dynamic(() => import('@/components/Coze'), {
ssr: false
})
const LA51 = dynamic(() => import('@/components/LA51'), {
ssr: false
})
const TianliGPT = dynamic(() => import('@/components/TianliGPT'), {
ssr: false
})

export default ExternalPlugin
12 changes: 8 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
}

Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 6 additions & 2 deletions lib/db/getSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export async function getGlobalData({
const siteIds = pageId?.split(',') || []
let data = EmptyData(pageId)

if (BLOG.BUNDLE_ANALYZER) {
return data
}

try {
for (let index = 0; index < siteIds.length; index++) {
const siteId = siteIds[index]
Expand Down Expand Up @@ -97,10 +101,10 @@ const EmptyData = pageId => {
id: 1,
title: `无法获取Notion数据,请检查Notion_ID: \n 当前 ${pageId}`,
summary:
'访问文档获取帮助→ https://tangly1024.com/article/vercel-deploy-notion-next',
'访问文档获取帮助 → https://docs.tangly1024.com/article/vercel-deploy-notion-next',
status: 'Published',
type: 'Post',
slug: '13a171332816461db29d50e9f575b00d',
slug: 'oops',
publishDay: '2024-11-13',
pageCoverThumbnail: BLOG.HOME_BANNER_IMAGE,
date: {
Expand Down

0 comments on commit 5be6d0b

Please sign in to comment.