diff --git a/components/Comment.js b/components/Comment.js index 3cc9b76e..d150e805 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -63,6 +63,7 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), { const Comment = ({ siteInfo, frontMatter, className }) => { const router = useRouter() + // 当连接中有特殊参数时跳转到评论区 if (isBrowser && ('giscus' in router.query || router.query.target === 'comment')) { setTimeout(() => { const url = router.asPath.replace('?target=comment', '') diff --git a/components/CommonScript.js b/components/CommonScript.js deleted file mode 100644 index 779432ba..00000000 --- a/components/CommonScript.js +++ /dev/null @@ -1,113 +0,0 @@ -import BLOG from '@/blog.config' - -/** - * 统计脚本 - * @returns {JSX.Element} - * @constructor - */ -const CommonScript = () => { - return (<> - - {BLOG.CHATBASE_ID && (<> - - - >)} - - {BLOG.COMMENT_DAO_VOICE_ID && (<> - {/* DaoVoice 反馈 */} - - - >)} - - {BLOG.AD_WWADS_ID && } - - {BLOG.COMMENT_CUSDIS_APP_ID && } - - {BLOG.COMMENT_TWIKOO_ENV_ID && } + + {siteConfig('COMMENT_TWIKOO_ENV_ID') && } + + {siteConfig('COMMENT_ARTALK_SERVER') && } + + {siteConfig('COMMENT_TIDIO_ID') && } + + {/* gitter聊天室 */} + {siteConfig('COMMENT_GITTER_ROOM') && (<> + + + >)} + + {/* 百度统计 */} + {siteConfig('ANALYTICS_BAIDU_ID') && ( + + )} + + {/* 站长统计 */} + {siteConfig('ANALYTICS_CNZZ_ID') && ( + + )} + + {/* 谷歌统计 */} + {siteConfig('ANALYTICS_GOOGLE_ID') && (<> + + + >)} + + > } export default ExternalPlugin diff --git a/components/Giscus.js b/components/Giscus.js index 0801ca3e..ed1564eb 100644 --- a/components/Giscus.js +++ b/components/Giscus.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import Giscus from '@giscus/react' diff --git a/components/WWAds.js b/components/WWAds.js index 8de07538..d1f786a4 100644 --- a/components/WWAds.js +++ b/components/WWAds.js @@ -1,4 +1,3 @@ -import React from 'react' import { siteConfig } from '@/lib/config' /** @@ -8,11 +7,13 @@ import { siteConfig } from '@/lib/config' * @returns {JSX.Element | null} - 返回渲染的 JSX 元素或 null */ export default function WWAds({ orientation = 'vertical', sticky = false, className }) { - if (!JSON.parse(siteConfig('AD_WWADS_ID'))) { + const adWWADSId = siteConfig('AD_WWADS_ID') + + if (!adWWADSId) { return null } - return ( -
- ) + return } diff --git a/next.config.js b/next.config.js index 0a8bd36d..aff79920 100644 --- a/next.config.js +++ b/next.config.js @@ -91,6 +91,7 @@ module.exports = withBundleAnalyzer({ // }) // } // 动态主题:添加 resolve.alias 配置,将动态路径映射到实际路径 + console.log('加载默认主题', path.resolve(__dirname, 'themes', THEME)) config.resolve.alias['@theme-components'] = path.resolve(__dirname, 'themes', THEME) return config }, diff --git a/pages/_document.js b/pages/_document.js index 9c7bd4c8..976a45fb 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -1,7 +1,6 @@ // eslint-disable-next-line @next/next/no-document-import-in-page import Document, { Html, Head, Main, NextScript } from 'next/document' import BLOG from '@/blog.config' -import CommonScript from '@/components/CommonScript' class MyDocument extends Document { static async getInitialProps(ctx) { @@ -14,7 +13,6 @@ class MyDocument extends Document { -