remove magic regexp

main
TZGyn 1 year ago
parent 33d7bf228b
commit 7d6685a44d
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

Binary file not shown.

@ -51,7 +51,6 @@
"formsnap": "^1.0.0", "formsnap": "^1.0.0",
"he": "^1.2.0", "he": "^1.2.0",
"lucide-svelte": "^0.418.0", "lucide-svelte": "^0.418.0",
"magic-regexp": "^0.8.0",
"mode-watcher": "^0.1.2", "mode-watcher": "^0.1.2",
"nanoid": "^5.0.3", "nanoid": "^5.0.3",
"node-html-parser": "^6.1.12", "node-html-parser": "^6.1.12",

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

Binary file not shown.

@ -13,7 +13,6 @@
"elysia": "^1.1.5", "elysia": "^1.1.5",
"elysia-rate-limit": "^4.1.0", "elysia-rate-limit": "^4.1.0",
"kysely": "^0.26.3", "kysely": "^0.26.3",
"magic-regexp": "^0.7.0",
"nanoid": "^5.0.1", "nanoid": "^5.0.1",
"pg": "^8.11.3", "pg": "^8.11.3",
"ua-parser-js": "^1.0.37", "ua-parser-js": "^1.0.37",

Loading…
Cancel
Save