{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "github-contributions", "title": "GitHub Contributions", "author": "tusharvarshney ", "description": "Visualize year-long GitHub contribution activity with daily counts, tooltips, and a profile link.", "dependencies": [ "date-fns" ], "registryDependencies": [ "tooltip", "spinner", "https://tusharvarshney.com/r/contribution-graph.json" ], "files": [ { "path": "src/registry/components/github-contributions/github-contributions.tsx", "content": "\"use client\"\n\nimport { format } from \"date-fns\"\nimport { use } from \"react\"\n\nimport { Spinner } from \"@/components/ui/spinner\"\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\"\nimport { cn } from \"@/lib/utils\"\nimport type { Activity } from \"@/registry/components/contribution-graph\"\nimport {\n ContributionGraph,\n ContributionGraphBlock,\n ContributionGraphCalendar,\n ContributionGraphFooter,\n ContributionGraphLegend,\n ContributionGraphTotalCount,\n} from \"@/registry/components/contribution-graph\"\n\nexport function GitHubContributions({\n contributions,\n githubProfileUrl,\n className,\n}: {\n contributions: Promise\n githubProfileUrl: string\n className?: string\n}) {\n const data = use(contributions)\n\n return (\n \n \n {({ activity, dayIndex, weekIndex }) => (\n \n \n \n \n \n \n \n

\n {activity.count} contribution{activity.count > 1 ? \"s\" : null}{\" \"}\n on {format(new Date(activity.date), \"dd.MM.yyyy\")}\n

\n
\n
\n )}\n \n\n \n \n {({ totalCount, year }) => (\n
\n {totalCount.toLocaleString(\"en\")} contributions in {year} on{\" \"}\n \n GitHub\n \n .\n
\n )}\n
\n\n \n
\n \n )\n}\n\nexport function GitHubContributionsFallback() {\n return (\n
\n \n
\n )\n}\n", "type": "registry:component", "target": "@components/github-contributions.tsx" }, { "path": "src/registry/components/github-contributions/lib/get-cached-contributions.ts", "content": "import { unstable_cache } from \"next/cache\"\n\nimport type { Activity } from \"@/registry/components/contribution-graph\"\n\ntype GitHubContributionsResponse = {\n contributions: Activity[]\n}\n\nexport const getCachedContributions = unstable_cache(\n async (username: string) => {\n const res = await fetch(\n `${process.env.GITHUB_CONTRIBUTIONS_API_URL || `https://github-contributions-api.jogruber.de`}/v4/${username}?y=last`\n )\n const data = (await res.json()) as GitHubContributionsResponse\n return data.contributions\n },\n [\"github-contributions\"],\n { revalidate: 86400 } // Cache for 1 day (86400 seconds)\n)\n", "type": "registry:lib", "target": "@lib/get-cached-contributions.ts" } ], "css": { "@utility link-underline": { "@apply underline decoration-current/30 decoration-1 underline-offset-3 transition-colors hover:decoration-current": {} } }, "docs": "https://tusharvarshney.com/components/github-contributions", "type": "registry:component" }