-
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathindex.js
More file actions
93 lines (83 loc) · 3.15 KB
/
index.js
File metadata and controls
93 lines (83 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { useEffect, useState } from 'react';
import BrowserOnly from '@docusaurus/BrowserOnly';
import clsx from 'clsx';
import styles from './styles.module.css';
const AD_REFRESH_RATE = 20 * 1000;
// ====== ✅ Ad Variants ======
function CodeHarborHubIntro({ position }) {
return (
<a
className={clsx(styles.container, styles.backgroundIntro)}
href="https://codeharborhub.github.io/tutorial/"
target="_blank"
rel="noopener"
onClick={() => window.gtag?.('event', `codeharborhub.intro.${position}.click`)}>
<p className={styles.tagline}>
<strong className={styles.title}>🚀 Learn. Build. Grow.</strong>
Join <u>CodeHarborHub</u> to explore free tech roadmaps, advanced tutorials,
and career-ready projects. <u>Start your journey today!</u>
</p>
</a>
);
}
function CodeHarborHubCourses({ position }) {
return (
<a
className={clsx(styles.container, styles.backgroundCourses)}
href="https://codeharborhub.github.io/courses/"
target="_blank"
rel="noopener"
onClick={() => window.gtag?.('event', `codeharborhub.courses.${position}.click`)}>
<p className={styles.tagline}>
<strong className={styles.title}>🎯 Master Web Development</strong>
Beginner to advanced courses in <u>HTML, CSS, JS, React & AI</u> with hands-on
projects. <u>Learn at your own pace!</u>
</p>
</a>
);
}
function CodeHarborHubCommunity({ position }) {
return (
<a
className={clsx(styles.container, styles.backgroundCommunity)}
href="https://discord.gg/rGCZYcaHk7"
target="_blank"
rel="noopener"
onClick={() => window.gtag?.('event', `codeharborhub.community.${position}.click`)}>
<p className={styles.tagline}>
<strong className={styles.title}>🤝 Join Our Community</strong>
Connect with developers, get help on projects, and collaborate on open-source.
<u>Join our Discord now!</u>
</p>
</a>
);
}
// ====== ✅ Main Rotating Ad Component ======
export default React.memo(function SidebarAd({ position }) {
const [counter, setCounter] = useState(0);
useEffect(() => {
const timer = setTimeout(() => setCounter((c) => c + 1), AD_REFRESH_RATE);
return () => clearTimeout(timer);
}, [counter]);
return (
<BrowserOnly key={counter}>
{() => {
const rand = Math.random();
const path = window.location.pathname;
// Dynamic placement based on page
if (path.includes('roadmap')) {
return rand < 0.5
? <CodeHarborHubCourses key={Math.random()} position={position} />
: <CodeHarborHubIntro key={Math.random()} position={position} />;
}
if (path.includes('community')) {
return <CodeHarborHubCommunity key={Math.random()} position={position} />;
}
// Default Rotation
if (rand < 0.33) return <CodeHarborHubIntro key={Math.random()} position={position} />;
if (rand < 0.66) return <CodeHarborHubCourses key={Math.random()} position={position} />;
return <CodeHarborHubCommunity key={Math.random()} position={position} />;
}}
</BrowserOnly>
);
});