Skip to content

Commit f671113

Browse files
committed
refactor: update anchor ads implementation on docs
1 parent 8caddca commit f671113

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

docs/src/css/custom.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,12 @@
9191
.example-container .example-padding {
9292
padding: 48px;
9393
}
94+
95+
.adsanchor {
96+
bottom: 0;
97+
display: block;
98+
position: fixed;
99+
width: 100%;
100+
max-height: 100px;
101+
height: 75px;
102+
}

docs/src/theme/Footer/index.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import Footer from '@theme-original/Footer'
44
// import AdsContainerElement from '@site/src/components/AdsContainerElement'
55

66
export default function FooterWrapper(props) {
7-
let shadoWindow = null
8-
97
useEffect(() => {
108
if (typeof window !== 'undefined') {
11-
shadoWindow = window
129
const scriptElement = document.createElement('script')
1310
scriptElement.src =
1411
'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7420210265158247'
@@ -21,27 +18,19 @@ export default function FooterWrapper(props) {
2118
}
2219
}
2320
document.body.appendChild(scriptElement)
21+
22+
const adsElement = document.createElement('ins')
23+
adsElement.classList.add('adsbygoogle')
24+
adsElement.classList.add('adsanchor')
25+
adsElement.setAttribute('ad-client', 'ca-pub-7420210265158247')
26+
adsElement.setAttribute('ad-slot', '8159529807')
27+
adsElement.setAttribute('full-width-responsive', 'true')
28+
document.body.appendChild(adsElement)
2429
}
2530
}, [])
2631

2732
return (
2833
<>
29-
{shadoWindow && shadoWindow.document.body.clientWidth <= 768 && (
30-
<ins
31-
className="adsbygoogle"
32-
style={{
33-
bottom: 0,
34-
display: 'block',
35-
position: 'fixed',
36-
width: '100%',
37-
maxHeight: '100px',
38-
height: '75px',
39-
}}
40-
data-ad-client="ca-pub-7420210265158247"
41-
data-ad-slot="8159529807"
42-
data-full-width-responsive="true"
43-
/>
44-
)}
4534
<Footer {...props} />
4635
{/* <AdsContainerElement id="mobile-anchor-ads" /> */}
4736
</>

0 commit comments

Comments
 (0)