File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed
Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,41 @@ import CustomSidebar from '@/components/custom-sidebar';
55import { Navbar } from '@/components/navbar' ;
66import { 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 ,
You can’t perform that action at this time.
0 commit comments