add stable media support and sync skillhub UI
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import type { Locale } from "@/lib/site-content";
|
||||
|
||||
function localize(locale: Locale, path: string) {
|
||||
if (!path || path === "/") {
|
||||
return `/${locale}`;
|
||||
}
|
||||
return `/${locale}${path}`;
|
||||
}
|
||||
|
||||
function isActive(pathname: string, href: string) {
|
||||
if (href === "/") {
|
||||
return pathname === href;
|
||||
}
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export function MainNav({
|
||||
locale,
|
||||
labels,
|
||||
}: {
|
||||
locale: Locale;
|
||||
labels: {
|
||||
home: string;
|
||||
docs: string;
|
||||
skills: string;
|
||||
console: string;
|
||||
pricing: string;
|
||||
};
|
||||
}) {
|
||||
const pathname = usePathname();
|
||||
const items = [
|
||||
{ href: localize(locale, "/"), label: labels.home },
|
||||
{ href: localize(locale, "/docs"), label: labels.docs },
|
||||
{ href: localize(locale, "/skills"), label: labels.skills },
|
||||
{ href: localize(locale, "/console"), label: labels.console },
|
||||
{ href: localize(locale, "/pricing"), label: labels.pricing },
|
||||
];
|
||||
|
||||
return (
|
||||
<nav className="main-nav" aria-label="Primary">
|
||||
{items.map((item) => (
|
||||
<Link
|
||||
aria-current={isActive(pathname, item.href) ? "page" : undefined}
|
||||
className={`nav-link ${isActive(pathname, item.href) ? "nav-link-active" : ""}`}
|
||||
href={item.href}
|
||||
key={item.href}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user