From 4838df315931bb883f704ec3e1abe2685f296cdf Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sat, 22 Apr 2023 19:52:26 +0800 Subject: 😀 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/SiteSwitcher.tsx | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 docs/components/SiteSwitcher.tsx (limited to 'docs/components/SiteSwitcher.tsx') diff --git a/docs/components/SiteSwitcher.tsx b/docs/components/SiteSwitcher.tsx new file mode 100644 index 0000000..e5d58d2 --- /dev/null +++ b/docs/components/SiteSwitcher.tsx @@ -0,0 +1,66 @@ +import cn from "classnames"; +import { useRouter } from "next/router"; +import Link from "next/link"; + +export type TurboSite = "pack" | "repo"; + +export function useTurboSite(): TurboSite | undefined { + const { pathname } = useRouter(); + + if (pathname.startsWith("/repo")) { + return "repo"; + } + + if (pathname.startsWith("/pack")) { + return "pack"; + } + + return undefined; +} + +function SiteSwitcherLink({ href, text, isActive }) { + const classes = + "py-1 transition-colors duration-300 inline-block w-[50px] cursor-pointer hover:text-black dark:hover:text-white"; + + const conditionalClasses = { + "text-black dark:text-white": !!isActive, + }; + + return ( + + {text} + + ); +} + +function SiteSwitcher() { + const site = useTurboSite(); + + return ( +
+ + + + + + +
+ ); +} + +export default SiteSwitcher; -- cgit v1.2.3-70-g09d2