diff --git a/blog.config.js b/blog.config.js
index 9c290861..6e2ff263 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -292,6 +292,7 @@ const BLOG = {
// 谷歌广告
ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx
+ ADSENSE_GOOGLE_TEST: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_TEST || false, // 谷歌广告ID测试模式,这种模式获取假的测试广告,用于开发 https://www.tangly1024.com/article/local-dev-google-adsense
// 自定义配置notion数据库字段名
NOTION_PROPERTY_NAME: {
diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js
index def8cb06..83ffc006 100644
--- a/components/GoogleAdsense.js
+++ b/components/GoogleAdsense.js
@@ -48,16 +48,18 @@ const AdSlot = ({ type = 'show' }) => {
style={{ display: 'block', textAlign: 'center' }}
data-ad-layout="in-article"
data-ad-format="fluid"
+ data-adtest={BLOG.ADSENSE_GOOGLE_TEST ? 'on' : 'off'}
data-ad-client={BLOG.ADSENSE_GOOGLE_ID}
data-ad-slot="3806269138">
}
- // 信息流广告
+ // 信息流广告
if (type === 'flow') {
return
}
@@ -67,6 +69,7 @@ const AdSlot = ({ type = 'show' }) => {
return
}
@@ -75,6 +78,7 @@ const AdSlot = ({ type = 'show' }) => {
return
diff --git a/themes/gitbook/LayoutBase.js b/themes/gitbook/LayoutBase.js
index 98883245..bea5acc3 100644
--- a/themes/gitbook/LayoutBase.js
+++ b/themes/gitbook/LayoutBase.js
@@ -17,6 +17,7 @@ import { useRouter } from 'next/router'
import Announcement from './components/Announcement'
import PageNavDrawer from './components/PageNavDrawer'
import FloatTocButton from './components/FloatTocButton'
+import { AdSlot } from '@/components/GoogleAdsense'
const ThemeGlobalMedium = createContext()
/**
@@ -65,6 +66,8 @@ const LayoutBase = (props) => {
{/* 所有文章列表 */}