@@ -3,6 +3,7 @@ import Link from "@docusaurus/Link";
33import { Analytics } from "@vercel/analytics/react" ;
44import clsx from "clsx" ; // Import clsx for conditional classes
55import styles from "./Root.module.css" ; // Import the CSS module
6+ import { useLocation } from "@docusaurus/router" ;
67
78// A simple Trophy SVG icon component
89function TrophyIcon ( ) {
@@ -33,6 +34,11 @@ export default function Root({ children }: { children: React.ReactNode }) {
3334 const [ showToast , setShowToast ] = useState ( false ) ;
3435 const [ isDark , setIsDark ] = useState ( false ) ;
3536 const timerRef = useRef < NodeJS . Timeout | null > ( null ) ;
37+ const location = useLocation ( ) ;
38+ const [ isInitialLoad , setIsInitialLoad ] = useState ( true ) ;
39+
40+ // Check if current page is sponsors page
41+ const isSponsorsPage = location . pathname === '/our-sponsors/' || location . pathname === '/our-sponsors' ;
3642
3743 // Theme detection logic
3844 useEffect ( ( ) => {
@@ -50,17 +56,47 @@ export default function Root({ children }: { children: React.ReactNode }) {
5056 attributeFilter : [ "data-theme" , "class" ] ,
5157 } ) ;
5258
53- // Show toast and set timer
54- setShowToast ( true ) ;
55- timerRef . current = setTimeout ( ( ) => setShowToast ( false ) , 10000 ) ;
59+ return ( ) => {
60+ observer . disconnect ( ) ;
61+ } ;
62+ } , [ ] ) ;
63+
64+ // Show toast on initial load for all pages
65+ useEffect ( ( ) => {
66+ if ( isInitialLoad ) {
67+ setShowToast ( true ) ;
68+ timerRef . current = setTimeout ( ( ) => setShowToast ( false ) , 10000 ) ;
69+ setIsInitialLoad ( false ) ;
70+ }
5671
5772 return ( ) => {
5873 if ( timerRef . current ) {
5974 clearTimeout ( timerRef . current ) ;
6075 }
61- observer . disconnect ( ) ;
6276 } ;
63- } , [ ] ) ;
77+ } , [ isInitialLoad ] ) ;
78+
79+ // Show toast on navigation only for sponsors page
80+ useEffect ( ( ) => {
81+ if ( ! isInitialLoad && isSponsorsPage ) {
82+ if ( timerRef . current ) {
83+ clearTimeout ( timerRef . current ) ;
84+ }
85+
86+ setShowToast ( false ) ;
87+ const showTimer = setTimeout ( ( ) => {
88+ setShowToast ( true ) ;
89+ timerRef . current = setTimeout ( ( ) => setShowToast ( false ) , 10000 ) ;
90+ } , 200 ) ;
91+
92+ return ( ) => {
93+ clearTimeout ( showTimer ) ;
94+ if ( timerRef . current ) {
95+ clearTimeout ( timerRef . current ) ;
96+ }
97+ } ;
98+ }
99+ } , [ location . pathname , isInitialLoad ] ) ;
64100
65101 // Handle manual close
66102 const handleCloseToast = ( ) => {
@@ -84,11 +120,23 @@ export default function Root({ children }: { children: React.ReactNode }) {
84120 >
85121 < TrophyIcon />
86122 < div className = { styles . toastContent } >
87- Check out our latest{ " " }
88- < Link to = "/dashboard#leaderboard" className = { styles . toastLink } >
89- leaderboard
90- </ Link >
91- !
123+ { isSponsorsPage ? (
124+ < >
125+ Do u want to get{ " " }
126+ < Link to = "/dashboard#leaderboard" className = { styles . toastLink } >
127+ sponsored
128+ </ Link >
129+ ?
130+ </ >
131+ ) : (
132+ < >
133+ Check out our latest{ " " }
134+ < Link to = "/dashboard#leaderboard" className = { styles . toastLink } >
135+ leaderboard
136+ </ Link >
137+ !
138+ </ >
139+ ) }
92140 </ div >
93141 < button
94142 onClick = { handleCloseToast }
0 commit comments