From 3f7a5e0fc10797d357e986d341cc3fafd2c5a9f9 Mon Sep 17 00:00:00 2001 From: Nik L Date: Tue, 14 Apr 2026 12:11:18 -0400 Subject: [PATCH] fix: github star count --- app/page.tsx | 2 -- components/hero.tsx | 31 ++++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index d91a19d..8ef23ca 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,5 +1,3 @@ -'use client' - import { PlatformProvider } from '@/components/platform-toggle' import { Nav } from '@/components/nav' import { Hero } from '@/components/hero' diff --git a/components/hero.tsx b/components/hero.tsx index b85cfd5..4a4bee3 100644 --- a/components/hero.tsx +++ b/components/hero.tsx @@ -1,15 +1,28 @@ -'use client' import { BetaSignup } from './beta-signup' -const badges = [ - { href: 'https://github.com/GreyhavenHQ/greywall', label: 'GitHub', value: '138 stars' }, - { href: 'https://github.com/GreyhavenHQ/greywall/blob/main/LICENSE', label: 'License', value: 'Apache-2.0' }, - { href: 'https://github.com/GreyhavenHQ/greywall/releases', label: 'Release', value: 'v0.3.1' }, - { href: 'https://github.com/GreyhavenHQ/greywall', label: 'Go', value: 'v1.25' }, - { href: 'https://www.producthunt.com/products/greywall?launch=greywall', label: 'Product Hunt', value: 'Greywall' }, -] +async function getStarCount(): Promise { + try { + const res = await fetch('https://api.github.com/repos/GreyhavenHQ/greywall', { + next: { revalidate: 3600 }, + headers: { Accept: 'application/vnd.github+json' }, + }) + if (!res.ok) return '138 stars' + const data = await res.json() + return typeof data.stargazers_count === 'number' ? `${data.stargazers_count} stars` : '138 stars' + } catch { + return '138 stars' + } +} -export function Hero() { +export async function Hero() { + const stars = await getStarCount() + const badges = [ + { href: 'https://github.com/GreyhavenHQ/greywall', label: 'GitHub', value: stars }, + { href: 'https://github.com/GreyhavenHQ/greywall/blob/main/LICENSE', label: 'License', value: 'Apache-2.0' }, + { href: 'https://github.com/GreyhavenHQ/greywall/releases', label: 'Release', value: 'v0.3.1' }, + { href: 'https://github.com/GreyhavenHQ/greywall', label: 'Go', value: 'v1.25' }, + { href: 'https://www.producthunt.com/products/greywall?launch=greywall', label: 'Product Hunt', value: 'Greywall' }, + ] return (