Use static assets instead of fetching from github (#156)

This commit is contained in:
Håvard Gjøby Thom 2024-11-09 20:06:54 +01:00 committed by GitHub
parent 2af11d145f
commit d199762427
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 136 additions and 107 deletions

View file

@ -1,5 +1,6 @@
"use client";
import { basePath } from "@/config/siteConfig";
import { cn } from "@/lib/utils";
import { cva, type VariantProps } from "class-variance-authority";
import { Clipboard, Copy } from "lucide-react";
@ -8,7 +9,6 @@ import * as React from "react";
import { toast } from "sonner";
import { Button } from "./button";
import { Separator } from "./separator";
import { basePath } from "@/config/siteConfig";
const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
@ -135,4 +135,4 @@ const CodeBlock = React.forwardRef<HTMLDivElement, CodeBlockProps>(
);
CodeBlock.displayName = "CodeBlock";
export { CodeBlock, buttonVariants };
export { buttonVariants, CodeBlock };

View file

@ -123,6 +123,6 @@ export {
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
NavigationMenuViewport,
navigationMenuTriggerStyle,
NavigationMenuViewport,
};

View file

@ -1,10 +1,10 @@
import { basePath } from "@/config/siteConfig";
import { cn } from "@/lib/utils";
import Link from "next/link";
import { useEffect, useState } from "react";
import { FaGithub, FaStar } from "react-icons/fa";
import NumberTicker from "./number-ticker";
import { buttonVariants } from "./button";
import { basePath } from "@/config/siteConfig";
import NumberTicker from "./number-ticker";
export default function StarOnGithubButton() {
const [stars, setStars] = useState(0);
@ -12,9 +12,12 @@ export default function StarOnGithubButton() {
useEffect(() => {
const fetchStars = async () => {
try {
const res = await fetch(`https://api.github.com/repos/community-scripts/${basePath}`, {
next: { revalidate: 60 * 60 * 24 },
});
const res = await fetch(
`https://api.github.com/repos/community-scripts/${basePath}`,
{
next: { revalidate: 60 * 60 * 24 },
},
);
if (res.ok) {
const data = await res.json();

View file

@ -1,9 +1,14 @@
"use client";
import { useTheme } from "next-themes";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip";
import { Button } from "./button";
import { MoonIcon, SunIcon } from "@radix-ui/react-icons";
import { useTheme } from "next-themes";
import { Button } from "./button";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "./tooltip";
export function ThemeToggle() {
const { setTheme, theme: currentTheme } = useTheme();