mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 18:56:17 +01:00
move application code into beszel folder
This commit is contained in:
24
beszel/site/src/components/router.tsx
Normal file
24
beszel/site/src/components/router.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createRouter } from '@nanostores/router'
|
||||
|
||||
export const $router = createRouter(
|
||||
{
|
||||
home: '/',
|
||||
server: '/system/:name',
|
||||
'forgot-password': '/forgot-password',
|
||||
},
|
||||
{ links: false }
|
||||
)
|
||||
|
||||
/** Navigate to url using router */
|
||||
export const navigate = (urlString: string) => {
|
||||
$router.open(urlString)
|
||||
}
|
||||
|
||||
function onClick(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) {
|
||||
e.preventDefault()
|
||||
$router.open(new URL((e.target as HTMLAnchorElement).href).pathname)
|
||||
}
|
||||
|
||||
export const Link = (props: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
||||
return <a onClick={onClick} {...props}></a>
|
||||
}
|
||||
Reference in New Issue
Block a user