Skip to content

Commit

Permalink
Update repo.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbleasel committed Feb 15, 2025
1 parent b7a45bc commit 0b2551c
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions apps/docs/components/navbar/repo.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
import { Octokit } from '@octokit/rest';
import { cn } from '@repo/shadcn-ui/lib/utils';
import { StarIcon } from 'lucide-react';
import { unstable_cache } from 'next/cache';

if (!process.env.GITHUB_TOKEN) {
throw new Error('GITHUB_TOKEN is not set');
}

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
});
export const Repo = async () => {
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
});

const getRepo = unstable_cache(async () => {
const { data } = await octokit.rest.repos.get({
const repo = await octokit.rest.repos.get({
owner: 'haydenbleasel',
repo: 'kibo',
});

return data;
}, ['github-repo-kibo']);

export const Repo = async () => {
const repo = await getRepo();

return (
<a
href={repo.html_url}
href={repo.data.html_url}
target="_blank"
rel="noreferrer"
className={cn(
Expand Down Expand Up @@ -53,12 +46,12 @@ export const Repo = async () => {
/>
</svg>
<span className="font-medium text-gray-700 text-sm group-hover:text-primary dark:text-gray-300 dark:group-hover:text-primary-light">
{repo.full_name}
{repo.data.full_name}
</span>
</div>
<div className="flex items-center gap-1 text-muted-foreground">
<StarIcon size={14} />
<span className="text-sm">{repo.stargazers_count}</span>
<span className="text-sm">{repo.data.stargazers_count}</span>
</div>
</div>
</a>
Expand Down

0 comments on commit 0b2551c

Please sign in to comment.