diff --git a/src/App.jsx b/src/App.jsx index 9edc418..a7d0ca1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,3 +1,9 @@ +import { useEffect, useState } from 'react'; + +const REDIRECT_HOST = 'luna.reversed.dev'; +const REDIRECT_TARGET = 'https://luna.spaceistyping.com'; +const REDIRECT_DELAY_SECONDS = 5; + const capabilities = [ { title: 'real help, not just replies', @@ -54,8 +60,41 @@ const contactCards = [ ]; function App() { + const [secondsLeft, setSecondsLeft] = useState(REDIRECT_DELAY_SECONDS); + const shouldRedirect = typeof window !== 'undefined' && window.location.hostname === REDIRECT_HOST; + + useEffect(() => { + if (!shouldRedirect) { + return undefined; + } + + setSecondsLeft(REDIRECT_DELAY_SECONDS); + + const countdownInterval = window.setInterval(() => { + setSecondsLeft((current) => (current > 1 ? current - 1 : 1)); + }, 1000); + + const redirectTimeout = window.setTimeout(() => { + window.location.replace(REDIRECT_TARGET); + }, REDIRECT_DELAY_SECONDS * 1000); + + return () => { + window.clearInterval(countdownInterval); + window.clearTimeout(redirectTimeout); + }; + }, [shouldRedirect]); + return (
+ luna.reversed.dev moved. redirecting you to{' '} + luna.spaceistyping.com + {' '}in {secondsLeft}s. +
+