diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js index 83ffc006..d9718369 100644 --- a/components/GoogleAdsense.js +++ b/components/GoogleAdsense.js @@ -2,6 +2,10 @@ import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { useEffect } from 'react' +/** + * 初始化谷歌广告 + * @returns + */ export default function GoogleAdsense() { const initGoogleAdsense = () => { setTimeout(() => { @@ -21,12 +25,8 @@ export default function GoogleAdsense() { } const router = useRouter() - useEffect(() => { - router.events.on('routeChangeComplete', initGoogleAdsense) - return () => { - router.events.off('routeChangeComplete', initGoogleAdsense) - } + initGoogleAdsense() }, [router]) return null diff --git a/themes/fukasawa/components/ArticleDetail.js b/themes/fukasawa/components/ArticleDetail.js index 21138fa1..37bc86c5 100644 --- a/themes/fukasawa/components/ArticleDetail.js +++ b/themes/fukasawa/components/ArticleDetail.js @@ -5,6 +5,7 @@ import ShareBar from '@/components/ShareBar' import { useGlobal } from '@/lib/global' import Link from 'next/link' import ArticleAround from './ArticleAround' +import { AdSlot } from '@/components/GoogleAdsense' /** * @@ -79,6 +80,8 @@ export default function ArticleDetail(props) { + + {/* Notion文章主体 */} diff --git a/themes/fukasawa/components/AsideLeft.js b/themes/fukasawa/components/AsideLeft.js index ba05d899..bf6edb45 100644 --- a/themes/fukasawa/components/AsideLeft.js +++ b/themes/fukasawa/components/AsideLeft.js @@ -11,6 +11,7 @@ import DarkModeButton from '@/components/DarkModeButton' import SocialButton from './SocialButton' import { useFukasawaGlobal } from '..' import CONFIG from '@/themes/fukasawa/config' +import { AdSlot } from '@/components/GoogleAdsense' // import { debounce } from 'lodash' // import { useEffect } from 'react' @@ -53,7 +54,7 @@ function AsideLeft(props) { // } // }, []) - return