docscn

GitHub info

A link to a GitHub repository with its star and fork counts.

Installation

npx shadcn@latest add @docscn/github-info

Usage

GithubInfo is a React Server Component that fetches the counts from GitHub's API, cached for 60 seconds. It fits in the sidebar's footer or the layout's links:

lib/layout.shared.tsx
import { GithubInfo } from "@/components/docs/components/github-info";

export function baseOptions(): BaseLayoutProps {
  return {
    links: [
      {
        type: "custom",
        children: <GithubInfo owner="ruiyuwg" repo="docscn" />,
      },
    ],
  };
}

Unauthenticated requests to GitHub's API are rate limited. Pass a token (for example process.env.GITHUB_TOKEN) on busy sites.

fetchRepositoryInfo() returns the counts without the link.

Props

Prop

Type