Skip to content

Commit fec3cda

Browse files
committed
fix: stars in docs
1 parent 809477b commit fec3cda

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

apps/docs/app/docs/layout.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,41 @@ import CustomSidebar from '@/components/custom-sidebar';
55
import { Navbar } from '@/components/navbar';
66
import { source } from '@/lib/source';
77

8-
export default function Layout({ children }: { children: ReactNode }) {
8+
async function getGithubStars(): Promise<number | null> {
9+
try {
10+
const response = await fetch(
11+
'https://api.github.com/repos/databuddy-analytics/databuddy',
12+
{
13+
headers: {
14+
Accept: 'application/vnd.github+json',
15+
},
16+
next: { revalidate: 3600 },
17+
}
18+
);
19+
20+
if (!response.ok) {
21+
return null;
22+
}
23+
24+
const data = (await response.json()) as { stargazers_count?: number };
25+
return typeof data.stargazers_count === 'number'
26+
? data.stargazers_count
27+
: null;
28+
} catch {
29+
return null;
30+
}
31+
}
32+
33+
export default async function Layout({ children }: { children: ReactNode }) {
34+
const stars = await getGithubStars();
35+
936
return (
1037
<DocsLayout
1138
tree={source.pageTree}
1239
{...baseOptions}
1340
nav={{
1441
enabled: true,
15-
component: <Navbar />,
42+
component: <Navbar stars={stars} />,
1643
}}
1744
sidebar={{
1845
enabled: true,

0 commit comments

Comments
 (0)