Skip to content

Commit

Permalink
use ISR for getting the version tag
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepistrol committed Feb 28, 2023
1 parent 8c5e822 commit fe3aa59
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions components/pages/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<Ribbon onClick={() => window.open(links.githubProject)}>
CodeEdit is currently in development. Check out the roadmap.
</Ribbon>
<HeroSection />
<HeroSection versionNumber={versionNumber}/>
<IntroFeaturesSection />
{/* <SampleStorySection /> */}
{/* <SampleStorySection /> */}
Expand Down
5 changes: 1 addition & 4 deletions components/pages/home/sections/HeroSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ 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;
margin-left: auto;
margin-right: auto;
`;

const HeroSection = () => {

const versionNumber = useLatestVersionNumber();
const HeroSection = ({versionNumber}) => {

return (
<Parallax
Expand Down
17 changes: 0 additions & 17 deletions hooks/useLatestVersionNumber.js

This file was deleted.

20 changes: 19 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export { default } from '@/components/pages/home';
import HomePage from '@/components/pages/home';

export default function Home(props) {
return (
<HomePage versionNumber={props.versionNumber} />
);
}

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
};
}

0 comments on commit fe3aa59

Please sign in to comment.