Skip to content

Commit a915fc9

Browse files
committed
feat: add Google AdSense block below related posts section
1 parent d72229f commit a915fc9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pages/post/[id].tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ export default function Post({ postData, relatedPosts }: InferGetStaticPropsType
7070
const hasMoreRelated = visibleRelatedCount < relatedPosts.length;
7171

7272
useEffect(() => {
73-
try {
74-
(window.adsbygoogle = window.adsbygoogle || []).push({});
75-
} catch (e) {
76-
console.error("Adsbygoogle push error:", e);
77-
}
73+
setTimeout(() => {
74+
try {
75+
(window.adsbygoogle = window.adsbygoogle || []).push({});
76+
} catch (e) {
77+
console.error("Adsbygoogle push error:", e);
78+
}
79+
}, 500);
7880
}, []);
7981

8082
useEffect(() => {
@@ -167,7 +169,7 @@ export default function Post({ postData, relatedPosts }: InferGetStaticPropsType
167169
</div>
168170
)}
169171
{/* ads */}
170-
<div className="mt-10 flex justify-center">
172+
<div className="mt-10 flex justify-center min-h-[100px]">
171173
<ins
172174
className="adsbygoogle"
173175
style={{display: "block"}}

0 commit comments

Comments
 (0)