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
+ return
{/* 折叠按钮 */}
{CONFIG.SIDEBAR_COLLAPSE_BUTTON &&
{isCollapsed ?
:
}
@@ -82,6 +83,10 @@ function AsideLeft(props) {
+
+
{router.asPath !== '/tag' &&
diff --git a/themes/fukasawa/components/BlogListPage.js b/themes/fukasawa/components/BlogListPage.js
index 18799d8b..b48655f2 100644
--- a/themes/fukasawa/components/BlogListPage.js
+++ b/themes/fukasawa/components/BlogListPage.js
@@ -5,6 +5,7 @@ import BlogPostListEmpty from './BlogListEmpty'
import PaginationSimple from './PaginationSimple'
import { useEffect, useState } from 'react'
import { debounce } from 'lodash'
+import { AdSlot } from '@/components/GoogleAdsense'
/**
* 文章列表分页表格
* @param page 当前页
@@ -58,6 +59,12 @@ const BlogListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
))}
+ {BLOG.ADSENSE_GOOGLE_ID && (
+
+ )}
+
diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js
index 9427df1a..af73a189 100644
--- a/themes/fukasawa/index.js
+++ b/themes/fukasawa/index.js
@@ -18,6 +18,7 @@ import { createContext, useContext, useEffect, useState } from 'react'
import Link from 'next/link'
import { Transition } from '@headlessui/react'
import dynamic from 'next/dynamic'
+import { AdSlot } from '@/components/GoogleAdsense'
const Live2D = dynamic(() => import('@/components/Live2D'))
const Mark = dynamic(() => import('mark.js'))
@@ -69,6 +70,7 @@ const LayoutBase = (props) => {
+
@@ -77,7 +79,6 @@ const LayoutBase = (props) => {
@@ -156,7 +162,7 @@ const LayoutSearch = props => {
}
}, 300)
}, [router])
- return
+ return
}
/**