Skip to content

Commit

Permalink
Merge pull request #180 from eatski/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eatski authored Apr 14, 2024
2 parents 151b816 + 8c542c2 commit 5c22a03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/components/ads/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Script from "next/script";
import { useEffect, useRef } from "react";
import { useEffect, useRef, useState } from "react";

export const Ads = () => {
const initialized = useRef<boolean>(false);
const [loaded, setLoaded] = useState(false);
useEffect(() => {
if (!loaded) {
return;
}
if (initialized.current) {
return;
}
Expand All @@ -16,13 +20,16 @@ export const Ads = () => {
} catch (e) {
console.error(e);
}
}, []);
}, [loaded]);
return (
<>
<Script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4007955646272580"
crossOrigin="anonymous"
onLoad={() => {
setLoaded(true);
}}
/>
<ins
className="adsbygoogle"
Expand Down
2 changes: 0 additions & 2 deletions src/pages/[markdownName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Layout } from "@/components/layout";
import { readFile } from "fs/promises";
import { GetStaticPaths, GetStaticProps } from "next";
import { resolve } from "path";
import Script from "next/script";
import { useEffect, useRef } from "react";
import { Ads } from "@/components/ads";

type Props = {
Expand Down

0 comments on commit 5c22a03

Please sign in to comment.