|
|
|
|
@ -2,15 +2,38 @@
|
|
|
|
|
import { page } from '$app/stores'
|
|
|
|
|
import { Button } from '$lib/components/ui/button'
|
|
|
|
|
import { cn } from '$lib/utils'
|
|
|
|
|
import { createRegExp, exactly, word } from 'magic-regexp'
|
|
|
|
|
|
|
|
|
|
let className: string | undefined = undefined
|
|
|
|
|
export { className as class }
|
|
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
|
{ href: '/', name: 'Home' },
|
|
|
|
|
{ href: '/links', name: 'Links' },
|
|
|
|
|
{ href: '/projects', name: 'Projects' },
|
|
|
|
|
{ href: '/settings/account', name: 'Settings' },
|
|
|
|
|
{
|
|
|
|
|
href: '/',
|
|
|
|
|
name: 'Home',
|
|
|
|
|
regex: createRegExp(exactly('/').notBefore(word)),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/links',
|
|
|
|
|
name: 'Links',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/links').or(exactly('/links/').before(word)),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/projects',
|
|
|
|
|
name: 'Projects',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/projects').or(exactly('/projects/').before(word)),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: '/settings/account',
|
|
|
|
|
name: 'Settings',
|
|
|
|
|
regex: createRegExp(
|
|
|
|
|
exactly('/settings').or(exactly('/settings/').before(word)),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
] as const
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
@ -23,7 +46,7 @@
|
|
|
|
|
<div class="flex flex-col gap-4 p-4">
|
|
|
|
|
{#each routes as route}
|
|
|
|
|
<Button
|
|
|
|
|
variant={$page.url.pathname == route.href
|
|
|
|
|
variant={route.regex.test($page.url.pathname)
|
|
|
|
|
? 'secondary'
|
|
|
|
|
: 'ghost'}
|
|
|
|
|
href={route.href}
|
|
|
|
|
|