From a5ee8f059c9da25b2668a1fe89fcedaf28dc39a0 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Nov 2024 21:01:38 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/config.js b/lib/config.js index 6985b320edf..7457ac3a3ae 100644 --- a/lib/config.js +++ b/lib/config.js @@ -4,6 +4,9 @@ import BLOG from '@/blog.config' import { useGlobal } from './global' import { deepClone, isUrl } from './utils' +const getValue = (value, fallback) => (hasVal(value) ? fallback : value) +const hasVal = value => value !== undefined && value !== null + /** * 读取配置顺序 * 1. 优先读取NotionConfig表 @@ -35,7 +38,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 +84,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 } From 9690d06fbdad8d3938f39792df03b73416332bca Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Nov 2024 21:25:01 +0800 Subject: [PATCH 2/4] fix --- lib/config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/config.js b/lib/config.js index 7457ac3a3ae..be7815b70b0 100644 --- a/lib/config.js +++ b/lib/config.js @@ -4,9 +4,6 @@ import BLOG from '@/blog.config' import { useGlobal } from './global' import { deepClone, isUrl } from './utils' -const getValue = (value, fallback) => (hasVal(value) ? fallback : value) -const hasVal = value => value !== undefined && value !== null - /** * 读取配置顺序 * 1. 优先读取NotionConfig表 @@ -21,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) { From c60a04af9943c1b96e230a3f26f757cb35ebe80f Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Nov 2024 22:43:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=86=E6=9E=90=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/db/getSiteData.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index fa3c37ba30d..1c2225d5a3c 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -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] @@ -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: { From 92107c47378ca7be4de95511005a4716bbe293e8 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Nov 2024 22:51:04 +0800 Subject: [PATCH 4/4] minify-external-plugins --- components/ExternalPlugins.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/ExternalPlugins.js b/components/ExternalPlugins.js index af9ffac117d..8e7ab3fc959 100644 --- a/components/ExternalPlugins.js +++ b/components/ExternalPlugins.js @@ -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' /** @@ -148,7 +146,7 @@ const ExternalPlugin = props => { {!CAN_COPY && } {WEB_WHIZ_ENABLED && } {AD_WWADS_BLOCK_DETECT && } - {TIANLI_KEY && } + {TIANLI_KEY && } {ENABLE_NPROGRSS && } @@ -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