Skip to content

Commit fe3aa59

Browse files
committed
use ISR for getting the version tag
1 parent 8c5e822 commit fe3aa59

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

components/pages/home/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import CtaSection from './sections/CtaSection';
1212
import SampleStorySection from './sections/SampleStorySection';
1313
import links from '@/data/links';
1414

15-
export default function HomePage() {
15+
export default function HomePage({ versionNumber }) {
1616
return (
1717
<div>
1818
<Ribbon onClick={() => window.open(links.githubProject)}>
1919
CodeEdit is currently in development. Check out the roadmap.
2020
</Ribbon>
21-
<HeroSection />
21+
<HeroSection versionNumber={versionNumber}/>
2222
<IntroFeaturesSection />
2323
{/* <SampleStorySection /> */}
2424
{/* <SampleStorySection /> */}

components/pages/home/sections/HeroSection.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ import Typography from '@/components/common/Typography';
66
import { Row, Column, Section, Stack } from '@/components/common/layout';
77
import HeroImage from '../HeroImage';
88
import Button from '../../../common/Button';
9-
import useLatestVersionNumber from '@/hooks/useLatestVersionNumber';
109

1110
const ProductIconWrap = styled.div`
1211
width: 128px;
1312
margin-left: auto;
1413
margin-right: auto;
1514
`;
1615

17-
const HeroSection = () => {
18-
19-
const versionNumber = useLatestVersionNumber();
16+
const HeroSection = ({versionNumber}) => {
2017

2118
return (
2219
<Parallax

hooks/useLatestVersionNumber.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

pages/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
export { default } from '@/components/pages/home';
1+
import HomePage from '@/components/pages/home';
2+
3+
export default function Home(props) {
4+
return (
5+
<HomePage versionNumber={props.versionNumber} />
6+
);
7+
}
8+
9+
export async function getStaticProps() {
10+
const res = await fetch('https://api.github.com/repos/CodeEditApp/CodeEdit/releases/latest');
11+
const data = await res.json();
12+
13+
return {
14+
props: {
15+
versionNumber: data.tag_name,
16+
},
17+
revalidate: 60 * 60 * 24, // 24 hours
18+
};
19+
}

0 commit comments

Comments
 (0)