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) => { {/* 所有文章列表 */} + + @@ -73,8 +76,12 @@ const LayoutBase = (props) => {
{slotTop} + + {onLoading ? LoadingCover : children} + + {/* 回顶按钮 */}
{ {/* 底部 */}
+ +
+ +
{/* 右侧侧推拉抽屉 */} @@ -95,7 +106,7 @@ const LayoutBase = (props) => {
-
+
{slotRight} {router.route === '/' && <> @@ -107,16 +118,18 @@ const LayoutBase = (props) => {
+ +
{showTocButton && !tocVisible &&
- +
} - + {/* 移动端底部导航栏 */} diff --git a/themes/gitbook/LayoutSlug.js b/themes/gitbook/LayoutSlug.js index b33d9b61..6a6bef08 100644 --- a/themes/gitbook/LayoutSlug.js +++ b/themes/gitbook/LayoutSlug.js @@ -9,6 +9,7 @@ import TocDrawer from './components/TocDrawer' import CategoryItem from './components/CategoryItem' import TagItemMini from './components/TagItemMini' import ShareBar from '@/components/ShareBar' +import { AdSlot } from '@/components/GoogleAdsense' export const LayoutSlug = (props) => { const { post, prev, next, lock, validPassword } = props @@ -41,6 +42,9 @@ export const LayoutSlug = (props) => {
{post?.type === 'Post' && } + + +