diff --git a/components/Navbar.tsx b/components/Navbar.tsx index badd865..1d1d473 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -4,14 +4,8 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; import logo from "../public/logo.png"; import Image from "next/image"; -import { FaGithub } from "react-icons/fa"; import { ModeToggle } from "./theme-toggle"; -import { - LuGitPullRequestDraft, - LuBookOpenCheck, - LuClipboardSignature, -} from "react-icons/lu"; -import { Coffee, Menu, MessageSquareText } from "lucide-react"; +import { Menu } from "lucide-react"; import { Sheet, SheetClose, @@ -75,31 +69,15 @@ function Navbar() { } }, [shouldFocusInput]); - useEffect(() => { - const loadLinksFromCache = () => { - const cacheKey = "scripts"; - const cachedLinks = localStorage.getItem(cacheKey); - - if (cachedLinks) { - setLinks(JSON.parse(cachedLinks)); - } else { - fetchLinks(); - } - }; - - loadLinksFromCache(); - }, []); - const fetchLinks = async () => { - try { - const res = await pb.collection("categories").getFullList({ - expand: "items", - requestKey: "navbar", - }); - setLinks(res as unknown as Category[]); - } catch (error) { - console.error("Error fetching links:", error); + const res = await fetch("/api/categories", { + next: { revalidate: 60 * 60 * 24 }, + }); + if (!res.ok) { + throw new Error("Failed to fetch categories"); } + const links = await res.json(); + setLinks(links); }; const removeCookieAndRedirect = () => { @@ -134,7 +112,7 @@ function Navbar() {
- +
-
+
{navBarLinks.map(({ href, event, icon, text }) => (