diff --git a/apps/www/app/(app)/page.tsx b/apps/www/app/(app)/page.tsx index 868d5fe..9c5b390 100644 --- a/apps/www/app/(app)/page.tsx +++ b/apps/www/app/(app)/page.tsx @@ -2,6 +2,7 @@ import Link from "next/link" import { IceCream } from "lucide-react" import { siteConfig } from "@/config/site" +import { ghStars } from "@/lib/fetchGhStars" import { cn } from "@/lib/utils" import { Badge } from "@/components/ui/badge" import { buttonVariants } from "@/components/ui/button" @@ -19,6 +20,7 @@ import { TemplateGrid } from "@/components/landing/template-grid" import { PageActions, PageHeader } from "@/components/page-header" export default function IndexPage() { + const stars = ghStars() return (
@@ -62,7 +64,7 @@ export default function IndexPage() { )} > - GitHub + GitHub {stars || "2.3k"}+ diff --git a/apps/www/app/(app)/themes/cards/create-account.tsx b/apps/www/app/(app)/themes/cards/create-account.tsx index e3743ee..1b40ea9 100644 --- a/apps/www/app/(app)/themes/cards/create-account.tsx +++ b/apps/www/app/(app)/themes/cards/create-account.tsx @@ -1,5 +1,6 @@ "use client" +import { ghStars } from "@/lib/fetchGhStars" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" @@ -14,6 +15,8 @@ import { } from "@/registry/default/ui/texture-card" export function CardsCreateAccount() { + const stars = ghStars() + return ( @@ -29,6 +32,7 @@ export function CardsCreateAccount() {
*/}
+ */} + + + {stars || "2.3k"}+ { + const res = await fetch("https://api.github.com/repos/nolly-studio/cult-ui", { + // Cache for 1 hour (3600 seconds) + next: { revalidate: 3600 }, + }) + + const data = await res.json() + const count = data.stargazers_count + + if (count >= 1_000_000) + return (count / 1_000_000).toFixed(1).replace(/\.0$/, "") + "M" + if (count >= 1_000) + return (count / 1_000).toFixed(1).replace(/\.0$/, "") + "k" + return count.toString() +} + +export async function ghStars() { + const stars = await getStars() + return stars +} + +// export default async function GitHubStars() { + +// return
⭐ GitHub Stars: {stars}
+// } diff --git a/apps/www/lib/utils.ts b/apps/www/lib/utils.ts index 1554847..3a8eda3 100644 --- a/apps/www/lib/utils.ts +++ b/apps/www/lib/utils.ts @@ -1,4 +1,3 @@ -import * as React from "react" import { clsx, type ClassValue } from "clsx" import { twMerge } from "tailwind-merge" diff --git a/apps/www/registry/default/example/texture-card-demo.tsx b/apps/www/registry/default/example/texture-card-demo.tsx index a324628..31fa880 100644 --- a/apps/www/registry/default/example/texture-card-demo.tsx +++ b/apps/www/registry/default/example/texture-card-demo.tsx @@ -2,6 +2,7 @@ import { ArrowRight, Merge } from "lucide-react" +import { ghStars } from "@/lib/fetchGhStars" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { TextureButton } from "@/registry/default/ui/texture-button" @@ -15,6 +16,8 @@ import { } from "@/registry/default/ui/texture-card" export default function TextureCardDemo() { + const stars = ghStars() + return (
@@ -80,6 +83,7 @@ export default function TextureCardDemo() { /> Github + {stars}
or