|
|
|
|
@ -3,7 +3,6 @@
|
|
|
|
|
import { Button } from '$lib/components/ui/button'
|
|
|
|
|
import { cn } from '$lib/utils'
|
|
|
|
|
import { Blocks, Home, Link, Settings } from 'lucide-svelte'
|
|
|
|
|
import { createRegExp, exactly, word } from 'magic-regexp'
|
|
|
|
|
|
|
|
|
|
let className: string | undefined = undefined
|
|
|
|
|
export { className as class }
|
|
|
|
|
@ -12,41 +11,25 @@
|
|
|
|
|
{
|
|
|
|
|
href: '/dashboard',
|
|
|
|
|
name: 'Home',
|
|
|
|
|
regex: createRegExp(exactly('/dashboard/').notBefore(word)),
|
|
|
|
|
match: (path: string) => path === '/dashboard',
|
|
|
|
|
icon: Home,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/dashboard/links',
|
|
|
|
|
name: 'Links',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/dashboard/links')
|
|
|
|
|
.at.lineStart()
|
|
|
|
|
.or(exactly('/dashboard/links/').notBefore(word).and(word)),
|
|
|
|
|
),
|
|
|
|
|
match: (path: string) => path.startsWith('/dashboard/links'),
|
|
|
|
|
icon: Link,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/dashboard/projects',
|
|
|
|
|
name: 'Projects',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/dashboard/projects')
|
|
|
|
|
.at.lineStart()
|
|
|
|
|
.or(
|
|
|
|
|
exactly('/dashboard/projects/').notBefore(word).and(word),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
match: (path: string) => path.startsWith('/dashboard/projects'),
|
|
|
|
|
icon: Blocks,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/dashboard/settings/account',
|
|
|
|
|
name: 'Settings',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/dashboard/settings')
|
|
|
|
|
.at.lineStart()
|
|
|
|
|
.or(
|
|
|
|
|
exactly('/dashboard/settings/').notBefore(word).and(word),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
match: (path: string) => path.startsWith('/dashboard/settings'),
|
|
|
|
|
icon: Settings,
|
|
|
|
|
},
|
|
|
|
|
] as const
|
|
|
|
|
@ -61,7 +44,7 @@
|
|
|
|
|
<div class="flex flex-col gap-4 p-2 lg:p-4">
|
|
|
|
|
{#each routes as route}
|
|
|
|
|
<Button
|
|
|
|
|
variant={route.regex.test($page.url.pathname)
|
|
|
|
|
variant={route.match($page.url.pathname)
|
|
|
|
|
? 'secondary'
|
|
|
|
|
: 'ghost'}
|
|
|
|
|
href={route.href}
|
|
|
|
|
|