update star us button
This commit is contained in:
31
src/app/components/github-star.tsx
Normal file
31
src/app/components/github-star.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import { ReactElement, useEffect, useState } from "react";
|
||||
import { Star } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
export function GithubStar(): ReactElement {
|
||||
const [starCount, setStarCount] = useState(0);
|
||||
|
||||
const getStarCount = async () => {
|
||||
const res = await fetch("https://api.github.com/repos/RealFascinated/minecraft-helper");
|
||||
const data = await res.json();
|
||||
return data.stargazers_count;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getStarCount().then(setStarCount);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Link
|
||||
className="bg-github-green px-2 py-1 rounded-lg flex items-center gap-1 hover:opacity-85 transform-gpu transition-all"
|
||||
href="https://github.com/RealFascinated/minecraft-helper"
|
||||
target="_blank"
|
||||
>
|
||||
<p className="text-white text-sm bg-secondary py-[3px] px-[4px] rounded-lg leading-none">{starCount}</p>
|
||||
<Star size={16} />
|
||||
<p className="text-white text-sm">Star us!</p>
|
||||
</Link>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user