perf: config home page

This commit is contained in:
archer
2023-09-01 10:13:57 +08:00
parent 2ae8d43216
commit 68cdf50cb6
15 changed files with 110 additions and 77 deletions

View File

@@ -1,16 +1,24 @@
import React, { useEffect } from 'react';
import React from 'react';
import { Box } from '@chakra-ui/react';
import { feConfigs } from '@/store/static';
import { serviceSideProps } from '@/utils/i18n';
import { useRouter } from 'next/router';
import Navbar from './components/Navbar';
import Hero from './components/Hero';
import Ability from './components/Ability';
import Choice from './components/Choice';
import Footer from './components/Footer';
import Loading from '@/components/Loading';
const Home = () => {
return (
const Home = ({ homeUrl = '/' }: { homeUrl: string }) => {
const router = useRouter();
if (homeUrl !== '/') {
router.replace(homeUrl);
}
return homeUrl === '/' ? (
<Box id="home" bg={'myWhite.600'} h={'100vh'} overflowY={'auto'} overflowX={'hidden'}>
<Box position={'fixed'} zIndex={10} top={0} left={0} right={0}>
<Navbar />
@@ -22,17 +30,22 @@ const Home = () => {
<Choice />
</Box>
</Box>
<Box bg={'white'}>
<Footer />
</Box>
{feConfigs?.show_git && (
<Box bg={'white'}>
<Footer />
</Box>
)}
</Box>
) : (
<Loading />
);
};
export async function getServerSideProps(content: any) {
return {
props: {
...(await serviceSideProps(content))
...(await serviceSideProps(content)),
homeUrl: process.env.HOME_URL || '/'
}
};
}