34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
"use client";
|
||
|
||
import Link from "next/link";
|
||
import { usePathname } from "next/navigation";
|
||
|
||
const ITEMS = [
|
||
{ href: "/", label: "Главная", match: (p: string) => p === "/" },
|
||
{ href: "/projects", label: "Проекты", match: (p: string) => p.startsWith("/projects") || p.startsWith("/p/") || p.startsWith("/t/") },
|
||
{ href: "/runners", label: "Раннеры", match: (p: string) => p.startsWith("/runners") },
|
||
{ href: "/help", label: "Помощь", match: (p: string) => p.startsWith("/help") },
|
||
];
|
||
|
||
export function Nav() {
|
||
const path = usePathname();
|
||
return (
|
||
<nav>
|
||
{ITEMS.map((i) => (
|
||
<Link key={i.href} href={i.href} className={i.match(path) ? "active" : undefined} aria-current={i.match(path) ? "page" : undefined}>
|
||
{i.label}
|
||
</Link>
|
||
))}
|
||
</nav>
|
||
);
|
||
}
|
||
|
||
export function SettingsLink() {
|
||
const active = usePathname().startsWith("/settings");
|
||
return (
|
||
<Link href="/settings" className={active ? "active" : undefined} aria-current={active ? "page" : undefined}>
|
||
Настройки
|
||
</Link>
|
||
);
|
||
}
|