diff --git a/components/CommonScript.js b/components/CommonScript.js
index f659c6b9..6912c3cc 100644
--- a/components/CommonScript.js
+++ b/components/CommonScript.js
@@ -38,10 +38,6 @@ const CommonScript = () => {
/>
>)}
- {/* GoogleAdsense 本地开发请加入 data-adbreak-test="on" */}
- {BLOG.ADSENSE_GOOGLE_ID && }
-
{BLOG.COMMENT_CUSDIS_APP_ID && }
{BLOG.COMMENT_TIDIO_ID && }
diff --git a/components/GoogleAdsense.js b/components/GoogleAdsense.js
index d9718369..b2edc130 100644
--- a/components/GoogleAdsense.js
+++ b/components/GoogleAdsense.js
@@ -1,4 +1,5 @@
import BLOG from '@/blog.config'
+import { loadExternalResource } from '@/lib/utils'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
@@ -8,20 +9,27 @@ import { useEffect } from 'react'
*/
export default function GoogleAdsense() {
const initGoogleAdsense = () => {
- setTimeout(() => {
- const ads = document.getElementsByClassName('adsbygoogle')
- const adsbygoogle = window.adsbygoogle
- if (ads.length > 0) {
- for (let i = 0; i <= ads.length; i++) {
- try {
- adsbygoogle.push(ads[i])
- console.log('adsbygoogle', i, ads[i], adsbygoogle)
- } catch (e) {
+ // GoogleAdsense 本地开发请加入 data-adbreak-test="on"
+ // {BLOG.ADSENSE_GOOGLE_ID && }
+ loadExternalResource(`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${BLOG.ADSENSE_GOOGLE_ID}`, 'js').then(url => {
+ setTimeout(() => {
+ const ads = document.getElementsByClassName('adsbygoogle')
+ const adsbygoogle = window.adsbygoogle
+ console.log('google-ads', adsbygoogle)
+ if (ads.length > 0) {
+ for (let i = 0; i <= ads.length; i++) {
+ try {
+ adsbygoogle.push(ads[i])
+ console.log('adsbygoogle', i, ads[i], adsbygoogle)
+ } catch (e) {
+
+ }
}
}
- }
- }, 100)
+ }, 100)
+ })
}
const router = useRouter()
diff --git a/themes/heo/components/CategoryBar.js b/themes/heo/components/CategoryBar.js
index bdc19e32..ee0a7a0c 100644
--- a/themes/heo/components/CategoryBar.js
+++ b/themes/heo/components/CategoryBar.js
@@ -41,7 +41,7 @@ export default function CategoryBar(props) {
{scrollRight ?
{/* 底部页面信息 */}
diff --git a/themes/heo/components/Hero.js b/themes/heo/components/Hero.js
index 5c781e67..211e3db7 100644
--- a/themes/heo/components/Hero.js
+++ b/themes/heo/components/Hero.js
@@ -162,11 +162,11 @@ function TopGroup(props) {