update Link component to support opening links in new tabs with ctrl/cmd key

This commit is contained in:
henrygd
2025-08-21 19:00:34 -04:00
parent 9d25181d1d
commit bbebb3e301

View File

@@ -41,8 +41,13 @@ export function Link(props: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
{...props}
onClick={(e) => {
e.preventDefault()
$router.open(new URL((e.currentTarget as HTMLAnchorElement).href).pathname)
props.onClick?.(e)
const href = props.href || ""
if (e.ctrlKey || e.metaKey) {
window.open(href, "_blank")
} else {
$router.open(href)
props.onClick?.(e)
}
}}
></a>
)