diff --git a/components/pages/home/index.js b/components/pages/home/index.js index f070160..de1824a 100644 --- a/components/pages/home/index.js +++ b/components/pages/home/index.js @@ -12,13 +12,13 @@ import CtaSection from './sections/CtaSection'; import SampleStorySection from './sections/SampleStorySection'; import links from '@/data/links'; -export default function HomePage() { +export default function HomePage({ versionNumber }) { return (
window.open(links.githubProject)}> CodeEdit is currently in development. Check out the roadmap. - + {/* */} {/* */} diff --git a/components/pages/home/sections/HeroSection.jsx b/components/pages/home/sections/HeroSection.jsx index 63f7b6d..22f4431 100644 --- a/components/pages/home/sections/HeroSection.jsx +++ b/components/pages/home/sections/HeroSection.jsx @@ -6,7 +6,6 @@ import Typography from '@/components/common/Typography'; import { Row, Column, Section, Stack } from '@/components/common/layout'; import HeroImage from '../HeroImage'; import Button from '../../../common/Button'; -import useLatestVersionNumber from '@/hooks/useLatestVersionNumber'; const ProductIconWrap = styled.div` width: 128px; @@ -14,9 +13,7 @@ const ProductIconWrap = styled.div` margin-right: auto; `; -const HeroSection = () => { - - const versionNumber = useLatestVersionNumber(); +const HeroSection = ({versionNumber}) => { return ( { - const [versionNumber, setVersionNumber] = useState(); - - useEffect(() => { - fetch('https://api.github.com/repos/CodeEditApp/CodeEdit/releases/latest') - .then((res) => res.json()) - .then((data) => { - setVersionNumber(data.name) - }) - }, []) - - return versionNumber ?? 'Loading...'; -}; - -export default useLatestVersionNumber; diff --git a/pages/index.js b/pages/index.js index 44d9018..d8e8212 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1 +1,19 @@ -export { default } from '@/components/pages/home'; +import HomePage from '@/components/pages/home'; + +export default function Home(props) { + return ( + + ); +} + +export async function getStaticProps() { + const res = await fetch('https://api.github.com/repos/CodeEditApp/CodeEdit/releases/latest'); + const data = await res.json(); + + return { + props: { + versionNumber: data.tag_name, + }, + revalidate: 60 * 60 * 24, // 24 hours + }; +}