Skip to content

Commit

Permalink
chore: add banner test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed May 27, 2024
1 parent 83852b2 commit 7827adf
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 9 deletions.
39 changes: 33 additions & 6 deletions docs/src/app/news/page.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
import "@/css/news.css";
import { AddBanner } from "@/components/Adsense";
import MainBg from "@/components/MainBg";

export default function NewsPage() {
const GOOGLE_ADSENSE_CLIENT_ID = process.env.GOOGLE_ADSENSE_CLIENT_ID ?? "";
const SlotAd1AndAd2 = "9630566447";
const SlotAd3 = "8700628151";
const SlotAd4 = "3500719479";
const SlotAd5AndAd6 = "7092033017";

return (
<MainBg>
<div id="news-page">
<div className="div-ad div-ad1">
<h1>News1</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd1AndAd2}
/>
</div>

<div className="div-ad div-ad2">
<h1>News2</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd1AndAd2}
/>
</div>

<div className="div-ad div-ad3">
<h1>News3</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd3}
AdFormat="fluid"
/>
</div>

<div className="div-ad div-ad4">
<h1>News4</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd4}
AdFormat="autorelaxed"
/>
</div>

<div className="div-ad div-ad5">
<h1>News5</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd5AndAd6}
/>
</div>

<div className="div-ad div-ad6">
<h1>News6</h1>
<AddBanner
AdClient={GOOGLE_ADSENSE_CLIENT_ID}
AdSlot={SlotAd5AndAd6}
/>
</div>
</div>
</MainBg>
Expand Down
31 changes: 31 additions & 0 deletions docs/src/components/Adsense/AddBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Script from "next/script";

interface AddBannerProps {
AdClient: string;
AdSlot: string;
AdFormat?: string;
FullWidthResponsive?: boolean;
}

export default function AddBanner({
AdClient,
AdSlot,
AdFormat = "auto",
FullWidthResponsive = true,
}: AddBannerProps) {
return (
<>
<ins
className="adsbygoogle"
style={{ display: "block" }}
data-ad-client={AdClient}
data-ad-slot={AdSlot}
data-ad-format={AdFormat}
data-full-width-responsive={FullWidthResponsive}
/>
<Script id="adsbygoogle-start" strategy="lazyOnload">
{`(adsbygoogle = window.adsbygoogle || []).push({});`}
</Script>
</>
);
}
33 changes: 33 additions & 0 deletions docs/src/components/Adsense/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Script from "next/script";

interface AdsenseProps {
GOOGLE_ADSENSE_CLIENT_ID: string | undefined;
}
Expand All @@ -11,3 +13,34 @@ export default function Adsense({ GOOGLE_ADSENSE_CLIENT_ID }: AdsenseProps) {
/>
);
}

interface AddBannerProps {
AdClient: string;
AdSlot: string;
AdFormat?: string;
FullWidthResponsive?: boolean;
}

// TEST
export function AddBanner({
AdClient,
AdSlot,
AdFormat = "auto",
FullWidthResponsive = true,
}: AddBannerProps) {
return (
<>
<ins
className="adsbygoogle"
style={{ display: "block" }}
data-ad-client={AdClient}
data-ad-slot={AdSlot}
data-ad-format={AdFormat}
data-full-width-responsive={FullWidthResponsive}
/>
<Script id="adsbygoogle-start" strategy="lazyOnload">
{`(adsbygoogle = window.adsbygoogle || []).push({});`}
</Script>
</>
);
}
1 change: 0 additions & 1 deletion docs/src/css/news.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
}
#news-page .div-ad {
border: 0.1px solid rgba(204, 204, 204, 0.4);
display: block;
border-radius: 5px;
width: 100%;
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/css/news.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/src/css/news.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

.div-ad {
border: 0.1px solid #cccccc66;
display: block;
border-radius: 5px;
width: 100%;
height: 100%;
Expand Down

0 comments on commit 7827adf

Please sign in to comment.