update star us button

This commit is contained in:
Lee
2024-04-19 15:22:03 +01:00
parent 1540daf269
commit bcf6c4867d
24 changed files with 396 additions and 406 deletions

View 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>
);
}