Skip to content

Commit dccf1d6

Browse files
authored
feat: Add GitHub stats to navbar (#12)
1 parent 86a23f0 commit dccf1d6

5 files changed

Lines changed: 43 additions & 2 deletions

File tree

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lucide-static": "^1.7.0",
2626
"react": "^19.2.4",
2727
"react-dom": "^19.2.4",
28+
"swr": "^2.4.1",
2829
"tailwind-merge": "^3.5.0",
2930
"vite": "^8.0.3"
3031
},

src/lib/layout.shared.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ export function baseOptions(): BaseLayoutProps {
1111
),
1212
transparentMode: "top",
1313
},
14-
githubUrl: "https://github.com/OrcaCD/orca-cd",
1514
};
1615
}

src/routes/docs/$.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Page() {
8585
const { path, pageTree, markdownUrl } = useFumadocsLoader(Route.useLoaderData());
8686

8787
return (
88-
<DocsLayout {...baseOptions()} tree={pageTree}>
88+
<DocsLayout {...baseOptions()} tree={pageTree} githubUrl="https://github.com/OrcaCD/orca-cd">
8989
<Suspense>{clientLoader.useContent(path, { markdownUrl, path })}</Suspense>
9090
</DocsLayout>
9191
);

src/routes/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
NavbarMenuLink,
2121
NavbarMenuTrigger,
2222
} from "fumadocs-ui/layouts/home/navbar";
23+
import { GithubInfo } from "fumadocs-ui/components/github-info";
24+
import useSWR from "swr";
2325

2426
export const Route = createFileRoute("/")({
2527
component: Home,
@@ -68,6 +70,12 @@ function SmallFeature({
6870
}
6971

7072
function Home() {
73+
const { data, isLoading } = useSWR(
74+
"https://api.github.com/repos/OrcaCD/orca-cd/releases/latest",
75+
// oxlint-disable-next-line promise/prefer-await-to-then
76+
(...args) => fetch(...args).then((res) => res.json()),
77+
);
78+
7179
return (
7280
<HomeLayout
7381
{...baseOptions()}
@@ -124,6 +132,25 @@ function Home() {
124132
</NavbarMenu>
125133
),
126134
},
135+
{
136+
type: "custom",
137+
secondary: true,
138+
children: (
139+
<a
140+
href="https://github.com/OrcaCD/orca-cd/releases"
141+
target="_blank"
142+
rel="noopener noreferrer"
143+
className="inline-flex items-center rounded-md border border-fd-border bg-fd-card px-1 py-0.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent"
144+
>
145+
{isLoading ? "..." : (data.tag_name ?? "No release yet")}
146+
</a>
147+
),
148+
},
149+
{
150+
type: "custom",
151+
secondary: true,
152+
children: <GithubInfo owner="OrcaCD" repo="orca-cd" className="flex-row" />,
153+
},
127154
]}
128155
>
129156
<section className="relative overflow-hidden border-b border-fd-border">

0 commit comments

Comments
 (0)