diff --git a/apps/marketing/src/app/(marketing)/open/gh-stars.tsx b/apps/marketing/src/app/(marketing)/open/gh-stars.tsx index 4d1d03254..4d5137a6a 100644 --- a/apps/marketing/src/app/(marketing)/open/gh-stars.tsx +++ b/apps/marketing/src/app/(marketing)/open/gh-stars.tsx @@ -15,45 +15,6 @@ type StargazersType = { }; }; -const data: StargazersType = { - '2023-8': { - stars: 2483, - forks: 155, - mergedPRs: 87, - openIssues: 67, - }, - '2023-7': { - stars: 2250, - forks: 0, - mergedPRs: 0, - openIssues: 0, - }, - '2023-6': { - stars: 2070, - forks: 0, - mergedPRs: 0, - openIssues: 0, - }, - '2023-5': { - stars: 1260, - forks: 0, - mergedPRs: 0, - openIssues: 0, - }, - '2023-4': { - stars: 90, - forks: 0, - mergedPRs: 0, - openIssues: 0, - }, - '2023-3': { - stars: 0, - forks: 0, - mergedPRs: 0, - openIssues: 0, - }, -}; - function formatMonth(monthStr: string) { const [year, month] = monthStr.split('-'); const monthNames = [ @@ -73,16 +34,16 @@ function formatMonth(monthStr: string) { return `${monthNames[parseInt(month, 10) - 1]} ${year}`; } -const formattedData = Object.keys(data) - .map((key) => ({ - month: formatMonth(key), - stars: data[key].stars, - })) - .reverse(); +export type GithubStarsProps = HTMLAttributes & { data: StargazersType }; -export type GithubStarsProps = HTMLAttributes; +export const GithubStars = ({ className, data, ...props }: GithubStarsProps) => { + const formattedData = Object.keys(data) + .map((key) => ({ + month: formatMonth(key), + stars: data[key].stars, + })) + .reverse(); -export const GithubStars = ({ className, ...props }: GithubStarsProps) => { return (

Github Monthly Stars

diff --git a/apps/marketing/src/app/(marketing)/open/page.tsx b/apps/marketing/src/app/(marketing)/open/page.tsx index bc7740b5a..d31ae067b 100644 --- a/apps/marketing/src/app/(marketing)/open/page.tsx +++ b/apps/marketing/src/app/(marketing)/open/page.tsx @@ -20,6 +20,17 @@ const ZMergedPullRequestsResponse = z.object({ total_count: z.number(), }); +const ZStargazersLiveResponse = z.record( + z.object({ + stars: z.number(), + forks: z.number(), + mergedPRs: z.number(), + openIssues: z.number(), + }), +); + +export type StargazersType = z.infer; + // const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse; export default async function OpenPage() { @@ -46,6 +57,14 @@ export default async function OpenPage() { .then((res) => res.json()) .then((res) => ZMergedPullRequestsResponse.parse(res)); + const STARGAZERS_DATA = await fetch('https://stargrazer-live.onrender.com/api/stats', { + headers: { + accept: 'application/json', + }, + }) + .then((res) => res.json()) + .then((res) => ZStargazersLiveResponse.parse(res)); + return (
@@ -88,7 +107,7 @@ export default async function OpenPage() { - +

Where's the rest?