Skip to content

Commit b879212

Browse files
committed
docs: ad banner
1 parent 8ce1135 commit b879212

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

website/docusaurus.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ const config = {
3333
'data-website-id': 'c15ead0d-e003-4fe0-8647-ddf0b560e38c',
3434
defer: true,
3535
},
36+
{
37+
src: 'https://media.ethicalads.io/media/client/ethicalads.min.js',
38+
async: true,
39+
type: 'text/javascript',
40+
}
3641
],
3742

3843
presets: [

website/src/css/custom.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,13 @@ html[data-theme='dark'] .docusaurus-highlight-code-line {
4444
max-width: 2440px;
4545
}
4646
}
47+
48+
.menu {
49+
display: flex;
50+
flex-direction: column;
51+
justify-content: space-between;
52+
}
53+
54+
#eab {
55+
margin: calc(var(--ifm-menu-link-padding-horizontal) + 0.5rem) 0 0 -0.5rem;
56+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { useEffect, useRef } from 'react';
2+
import { useColorMode } from '@docusaurus/theme-common';
3+
import OriginalDocSidebar from '@theme-original/DocSidebar';
4+
5+
export default function DocSidebar(props) {
6+
const bannerRef = useRef();
7+
const { colorMode } = useColorMode();
8+
9+
useEffect(() => {
10+
if (!document.getElementById('eab')) {
11+
const banner = document.createElement('div');
12+
13+
bannerRef.current = banner;
14+
banner.className = 'flat horizontal'
15+
banner.id = 'eab';
16+
banner.setAttribute('data-ea-publisher', 'react-chartjs-2jsorg');
17+
banner.setAttribute('data-ea-type', 'image');
18+
document.querySelector('.theme-doc-sidebar-menu')?.parentElement?.appendChild(banner);
19+
ethicalads.reload();
20+
}
21+
}, []);
22+
23+
useEffect(() => {
24+
bannerRef.current?.classList.toggle('dark', colorMode === 'dark');
25+
}, [colorMode]);
26+
27+
return (
28+
<OriginalDocSidebar {...props} />
29+
);
30+
}

0 commit comments

Comments
 (0)