34 lines
948 B
TypeScript
34 lines
948 B
TypeScript
import { wrapBasename } from "../../modules/basename";
|
|
import { clsx } from 'clsx';
|
|
|
|
export const Nav = () => {
|
|
const currentPath = typeof window !== 'undefined' ? window.location.pathname : ''
|
|
|
|
const navItems = [
|
|
{ name: '管理员设置', path: wrapBasename('/settings/') },
|
|
{ name: '全局设置', path: wrapBasename('/settings/all/') },
|
|
];
|
|
|
|
const isActive = (path: string) => {
|
|
return currentPath === path
|
|
}
|
|
|
|
return (
|
|
<nav className="space-y-2">
|
|
{navItems.map((item) => (
|
|
<a
|
|
key={item.path}
|
|
href={item.path}
|
|
className={clsx(
|
|
"block px-4 py-2 rounded transition-colors border-l-4",
|
|
isActive(item.path)
|
|
? "bg-gray-100 text-black border-black font-medium"
|
|
: "text-gray-700 border-transparent hover:bg-gray-50 hover:border-gray-300"
|
|
)}
|
|
>
|
|
{item.name}
|
|
</a>
|
|
))}
|
|
</nav>
|
|
)
|
|
} |