Skip to content

Commit

Permalink
Google AdSense
Browse files Browse the repository at this point in the history
  • Loading branch information
wxh06 committed Jun 7, 2024
1 parent fdd022f commit 6ea5638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/viewer/src/app/AdSense.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Script from "next/script";

export default function AdSense({ publisherId }: { publisherId: string }) {
return (
<Script
src={`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-${publisherId}`}
/>
);
}
4 changes: 4 additions & 0 deletions packages/viewer/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NavBar from "./NavBar";
import Footer from "./Footer";
import GoogleAnalytics from "./GoogleAnalytics";
import MicrosoftClarity from "./MicrosoftClarity";
import AdSense from "./AdSense";

export const metadata = {
title: "洛谷帖子保存站",
Expand All @@ -27,6 +28,9 @@ export default function RootLayout({ children }: React.PropsWithChildren) {
projectId={process.env.NEXT_PUBLIC_CLARITY_PROJECT_ID}
/>
)}
{process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID && (
<AdSense publisherId={process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID} />
)}
<NavBar />
<div className="container-lg" style={{ marginTop: "2rem" }}>
{/* <div
Expand Down

0 comments on commit 6ea5638

Please sign in to comment.