2024-08-08 23:32:46 +00:00
|
|
|
<script lang="ts">
|
2025-02-04 01:21:46 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2024-10-15 19:02:11 +00:00
|
|
|
import {goto} from "$app/navigation"
|
2025-02-04 03:28:29 +00:00
|
|
|
import {stopPropagation} from "@lib/html"
|
2024-08-08 23:32:46 +00:00
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {
|
|
|
|
|
children,
|
|
|
|
|
href,
|
|
|
|
|
external = false,
|
|
|
|
|
replaceState = false,
|
|
|
|
|
...restProps
|
|
|
|
|
}: {
|
|
|
|
|
children: Snippet
|
2025-02-04 00:37:14 +00:00
|
|
|
href: string
|
2025-02-04 01:21:46 +00:00
|
|
|
external?: boolean
|
|
|
|
|
replaceState?: boolean
|
|
|
|
|
disabled?: boolean
|
|
|
|
|
class?: string
|
2026-01-22 20:37:30 +00:00
|
|
|
'data-tip'?: string
|
2025-02-04 01:21:46 +00:00
|
|
|
} = $props()
|
2024-10-11 22:29:54 +00:00
|
|
|
|
2024-10-15 19:17:02 +00:00
|
|
|
const go = (e: Event) => {
|
|
|
|
|
if (!external) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
2024-10-24 18:52:02 +00:00
|
|
|
goto(href, {replaceState})
|
2024-10-15 19:17:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-08-08 23:32:46 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
{href}
|
2025-02-04 00:37:14 +00:00
|
|
|
{...restProps}
|
2025-02-04 01:21:46 +00:00
|
|
|
onclick={stopPropagation(go)}
|
2025-02-04 00:37:14 +00:00
|
|
|
class="cursor-pointer {restProps.class}"
|
2024-08-08 23:32:46 +00:00
|
|
|
rel={external ? "noopener noreferer" : ""}
|
|
|
|
|
target={external ? "_blank" : ""}>
|
2025-02-04 01:21:46 +00:00
|
|
|
{@render children?.()}
|
2024-08-08 23:32:46 +00:00
|
|
|
</a>
|