diff --git a/app/(landing)/landing.tsx b/app/(landing)/landing.tsx index 4a88fd9804..166cb0df3d 100644 --- a/app/(landing)/landing.tsx +++ b/app/(landing)/landing.tsx @@ -1,8 +1,7 @@ 'use client' import { useEffect, useState } from 'react' -import Image from 'next/image' -import { MessageSquare, Star, Twitter } from 'lucide-react' +import { Star } from 'lucide-react' import { GithubIcon } from '@/components/icons' import HeroWorkflowProvider from './hero-workflow' import { useWindowSize } from './use-window-size' @@ -44,9 +43,36 @@ const DiscordIcon = () => ( ) +// Fetch outside the component to avoid recreating it on each render +async function fetchGitHubStars() { + try { + const response = await fetch('https://api.github.com/repos/simstudioai/sim', { + next: { revalidate: 3600 }, // Cache for 1 hour + }) + if (response.ok) { + const data = await response.json() + return data.stargazers_count + } + } catch (error) { + console.error('Error fetching GitHub stars:', error) + } + return null +} + +const starCountPromise = fetchGitHubStars() + export default function Landing() { const { width } = useWindowSize() const isMobile = width !== undefined && width < 640 + const [starCount, setStarCount] = useState(null) + + useEffect(() => { + starCountPromise.then((count) => { + if (count !== null) { + setStarCount(count) + } + }) + }, []) return (
@@ -83,8 +109,12 @@ export default function Landing() { >
- 14 - + {starCount !== null && ( + <> + {starCount} + + + )}