Skip to content

Commit cc44f6c

Browse files
committed
add hook with gh api call for getting vers number
1 parent b9adf60 commit cc44f6c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

components/pages/home/sections/HeroSection.jsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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 { useState, useEffect } from 'react';
910

1011
const ProductIconWrap = styled.div`
1112
width: 128px;
@@ -14,6 +15,22 @@ const ProductIconWrap = styled.div`
1415
`;
1516

1617
const HeroSection = () => {
18+
19+
const [data, setData] = useState(null)
20+
const [isLoading, setLoading] = useState(false)
21+
const versionNumber = data?.name ?? 'Loading...'
22+
23+
useEffect(() => {
24+
setLoading(true)
25+
fetch('https://api.github.com/repos/CodeEditApp/CodeEdit/releases/latest')
26+
.then((res) => res.json())
27+
.then((data) => {
28+
setData(data)
29+
setLoading(false)
30+
})
31+
}, [])
32+
33+
1734
return (
1835
<Parallax
1936
style={{ overflow: 'visible' }}
@@ -42,7 +59,7 @@ const HeroSection = () => {
4259
CodeEdit is an exciting new code editor written entirely and unapologetically for macOS. Develop any project using any language at speeds like never before with increased efficiency and reliability in an editor that feels right at home on your Mac.
4360
</Typography>
4461
<Button href="https://github.com/CodeEditApp/CodeEdit/releases/latest" target="_blank">Download Alpha</Button>
45-
<Typography variant="body-reduced" color="tertiary">0.0.1-alpha | macOS 12+</Typography>
62+
<Typography variant="body-reduced" color="tertiary">{ versionNumber } | macOS 13+</Typography>
4663
</Stack>
4764
</Column>
4865
</Row>

0 commit comments

Comments
 (0)