Skip to content

Commit 0a35649

Browse files
María Paz Arrieta LandazuriMaría Paz Arrieta Landazuri
authored andcommitted
Move AdSense code to _document.tsx for better initialization
1 parent 1673b27 commit 0a35649

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

frontend/src/app/layout.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import "./globals.css";
44
import Header from "./components/Header";
55
import Footer from "./components/Footer";
66
import GoogleAnalytics from "./components/GoogleAnalytics";
7-
import Script from "next/script";
87

98
const inter = Inter({
109
variable: "--font-inter",
@@ -29,24 +28,7 @@ export default function RootLayout({
2928
}>) {
3029
return (
3130
<html lang="es">
32-
<head>
33-
<script
34-
async
35-
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5179832879235237"
36-
crossOrigin="anonymous"
37-
/>
38-
<script
39-
dangerouslySetInnerHTML={{
40-
__html: `
41-
window.adsbygoogle = window.adsbygoogle || [];
42-
window.adsbygoogle.push({
43-
google_ad_client: "ca-pub-5179832879235237",
44-
enable_page_level_ads: true
45-
});
46-
`,
47-
}}
48-
/>
49-
</head>
31+
<head />
5032
<body className={`${inter.variable} ${roboto.variable} antialiased`}>
5133
<GoogleAnalytics />
5234
<Header />

frontend/src/pages/_document.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Html, Head, Main, NextScript } from 'next/document'
2+
3+
export default function Document() {
4+
return (
5+
<Html lang="es">
6+
<Head>
7+
<script
8+
async
9+
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5179832879235237"
10+
crossOrigin="anonymous"
11+
/>
12+
<script
13+
dangerouslySetInnerHTML={{
14+
__html: `
15+
window.adsbygoogle = window.adsbygoogle || [];
16+
window.adsbygoogle.push({
17+
google_ad_client: "ca-pub-5179832879235237",
18+
enable_page_level_ads: true
19+
});
20+
`,
21+
}}
22+
/>
23+
</Head>
24+
<body>
25+
<Main />
26+
<NextScript />
27+
</body>
28+
</Html>
29+
)
30+
}

0 commit comments

Comments
 (0)