diff --git a/src/components/NewsLetterPopup.tsx b/src/components/NewsLetterPopup.tsx new file mode 100644 index 00000000..aef80069 --- /dev/null +++ b/src/components/NewsLetterPopup.tsx @@ -0,0 +1,95 @@ +import React, { useEffect, useState } from 'react'; + +const NewsletterPopup = () => { + const [showPopup, setShowPopup] = useState(false); + + useEffect(() => { + const hasSubscribed = localStorage.getItem('recodehive_newsletter_popup'); + + if (hasSubscribed !== 'true') { + const handleScroll = () => { + const scrollPosition = window.scrollY + window.innerHeight; + const pageHeight = document.body.scrollHeight; + + if ((scrollPosition / pageHeight) >= 0.8) { + setShowPopup(true); + window.removeEventListener('scroll', handleScroll); + } + }; + + window.addEventListener('scroll', handleScroll); + return () => window.removeEventListener('scroll', handleScroll); + } + }, []); + + const handleClose = () => { + setShowPopup(false); + localStorage.setItem('recodehive_newsletter_popup', 'true'); + }; + + if (!showPopup) return null; + + return ( +
+
+ RecodeHive Logo + +

Sanjay’s Substack

+ +

+ Recodehive is an inclusive and welcoming platform where everyone can contribute, + learn, and grow together. ⚡
+ Check my ✨ Website: https://www.recodehive.com
+ 📮 How to reach me: github.com/sanjay-kv
+ 👫 Join my opensource community +

+ +

+ By Sanjay Viswanathan · Over 31,000 subscribers +

+ +
{ + e.preventDefault(); + alert('Subscribed! (Integrate with Substack API)'); + handleClose(); + }} + > + + +
+ +

+ By subscribing, I agree to Substack’s{' '} + Terms of Use and acknowledge its{' '} + Information Collection Notice and{' '} + Privacy Policy. +

+ + +
+
+ ); +}; + +export default NewsletterPopup; diff --git a/src/theme/Layout.tsx b/src/theme/Layout.tsx index afccc538..74ff1a7a 100644 --- a/src/theme/Layout.tsx +++ b/src/theme/Layout.tsx @@ -1,12 +1,19 @@ import React from "react"; import Layout from "@theme-original/Layout"; import NavbarFirebaseAuthGithub from "@site/src/components/ui/NavbarFirebaseAuthGithub"; +import NewsletterPopup from '../components/NewsLetterPopup'; + + + +export default function CustomLayout({ children, ...props }) { -export default function CustomLayout(props) { return ( - // <> - - // - // - ); + <> + + + {children} + + + +); } \ No newline at end of file