Skip to content

Commit b4f7148

Browse files
authored
Merge pull request #13 from hyperweb-io/fix/seo-redirect
fix: seo redirect
2 parents f75d71a + 9b83f81 commit b4f7148

12 files changed

+298
-211
lines changed

components/redirect-splash-page.tsx

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
import Image from "next/image";
2+
import { useState, useEffect } from "react";
3+
import { FaArrowRightLong, FaClock } from "react-icons/fa6";
4+
import {
5+
Button,
6+
Box,
7+
Text,
8+
VStack,
9+
HStack,
10+
Container,
11+
Flex,
12+
ChakraProvider,
13+
useColorModeValue,
14+
} from "@chakra-ui/react";
15+
16+
// Get the redirect URL from environment variables with a fallback
17+
const REDIRECT_URL =
18+
process.env.NEXT_PUBLIC_REDIRECT_URL ?? "https://docs.hyperweb.io";
19+
20+
export function RedirectSplashPage({
21+
fallbackChildran,
22+
}: {
23+
fallbackChildran: React.ReactNode;
24+
}) {
25+
const [countdown, setCountdown] = useState(30);
26+
const [isCancelled, setIsCancelled] = useState(false);
27+
28+
// Color mode values
29+
const bgColor = useColorModeValue("white", "gray.800");
30+
const borderColor = useColorModeValue("gray.200", "gray.700");
31+
const textColor = useColorModeValue("gray.600", "gray.400");
32+
const accentColor = useColorModeValue("#0066CC", "#3B82F6");
33+
const arrowColor = useColorModeValue("gray.700", "gray.400");
34+
35+
const redirectToSite = () => {
36+
window.location.href = REDIRECT_URL;
37+
};
38+
39+
useEffect(() => {
40+
if (isCancelled) return;
41+
42+
const timer = setInterval(() => {
43+
setCountdown((prev) => {
44+
if (prev <= 1) {
45+
clearInterval(timer);
46+
redirectToSite();
47+
return 1;
48+
}
49+
return prev - 1;
50+
});
51+
}, 1000);
52+
return () => clearInterval(timer);
53+
}, [isCancelled]);
54+
55+
const handleCancel = () => {
56+
setIsCancelled(true);
57+
setCountdown(0);
58+
};
59+
60+
if (isCancelled) {
61+
return fallbackChildran;
62+
}
63+
64+
return (
65+
<ChakraProvider>
66+
<Flex
67+
w="100%"
68+
h="50vh"
69+
align="center"
70+
justify="center"
71+
bg={bgColor}
72+
my={18}
73+
>
74+
<Container
75+
maxW="600px"
76+
py={12}
77+
px={8}
78+
display="flex"
79+
flexDirection="column"
80+
alignItems="center"
81+
bg={bgColor}
82+
boxShadow="lg"
83+
borderRadius="lg"
84+
borderWidth="1px"
85+
borderColor={borderColor}
86+
>
87+
<HStack spacing={6} pb={10}>
88+
<Image
89+
src="/brand/cosmology-darker.svg"
90+
alt="Cosmology"
91+
height={0}
92+
width={0}
93+
style={{ width: "45px", height: "45px" }}
94+
/>
95+
<Box color={arrowColor}>
96+
<FaArrowRightLong size={24} />
97+
</Box>
98+
<Image
99+
src="/brand/hyperweb.svg"
100+
alt="Hyperweb"
101+
height={0}
102+
width={0}
103+
style={{ width: "45px", height: "45px" }}
104+
/>
105+
</HStack>
106+
107+
<Text
108+
fontSize={{ base: "2xl", md: "3xl" }}
109+
fontWeight="semibold"
110+
textAlign="center"
111+
mb={2}
112+
>
113+
Hyperweb Docs is the new home for Cosmology Zone Docs.
114+
</Text>
115+
116+
<Text color={textColor} maxW="440px" fontSize="md" textAlign="center">
117+
Check out our new docs over at Hyperweb for existing products' docs
118+
and much more.
119+
</Text>
120+
121+
<HStack spacing={6} mt={10} mb={8}>
122+
<Box color={accentColor}>
123+
<FaClock size={16} />
124+
</Box>
125+
<Text fontSize="md" fontWeight="medium" color={accentColor}>
126+
Redirecting to Hyperweb Docs in{" "}
127+
<Text as="span" fontSize="lg" fontWeight="semibold">
128+
{countdown}
129+
</Text>{" "}
130+
second{countdown === 1 ? "" : "s"}...
131+
</Text>
132+
</HStack>
133+
134+
<Box px={10} w="full">
135+
<HStack spacing={4}>
136+
<Button
137+
size="sm"
138+
variant="outline"
139+
onClick={handleCancel}
140+
w="full"
141+
borderColor={accentColor}
142+
color={accentColor}
143+
>
144+
Stay here
145+
</Button>
146+
<Button
147+
size="sm"
148+
bg={accentColor}
149+
color="white"
150+
onClick={redirectToSite}
151+
w="full"
152+
_hover={{
153+
bg: useColorModeValue("#0052A3", "#2563EB"),
154+
}}
155+
>
156+
Redirect now
157+
</Button>
158+
</HStack>
159+
</Box>
160+
</Container>
161+
</Flex>
162+
</ChakraProvider>
163+
);
164+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"nextra-theme-docs": "^2.9.0",
3636
"react": "^18.2.0",
3737
"react-dom": "^18.2.0",
38-
"react-icons": "4.4.0"
38+
"react-icons": "^5.4.0"
3939
},
4040
"devDependencies": {
4141
"@types/node": "20.10.0",
@@ -50,4 +50,4 @@
5050
"injected": true
5151
}
5252
}
53-
}
53+
}

pages/_app.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { ChainProvider } from "@cosmos-kit/react";
77
import { useConfig } from "nextra-theme-docs";
88
import { ThemeProvider, useTheme } from "@interchain-ui/react";
99
import { useNextraTheme } from "../components/hooks";
10-
11-
// import { makeWeb3AuthWallets } from "@cosmos-kit/web3auth";
10+
import { RedirectSplashPage } from "../components/redirect-splash-page";
1211
import "nextra-theme-docs/style.css";
1312
import React from "react";
1413

14+
// import { makeWeb3AuthWallets } from "@cosmos-kit/web3auth";
15+
1516
function MyApp({ Component, pageProps }: AppProps) {
1617
// const web3AuthWallets = useMemo(
1718
// () =>
@@ -82,7 +83,7 @@ function MyApp({ Component, pageProps }: AppProps) {
8283
}}
8384
>
8485
<div className={themeClass}>
85-
<Component {...pageProps} />
86+
<RedirectSplashPage fallbackChildran={<Component {...pageProps} />} />
8687
</div>
8788
</ChainProvider>
8889
</ThemeProvider>

public/brand/cosmology-darker.svg

Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Loading

public/brand/cosmology-horizontal.svg

Lines changed: 18 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)