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} {...props}
onClick={(e) => { onClick={(e) => {
e.preventDefault() e.preventDefault()
$router.open(new URL((e.currentTarget as HTMLAnchorElement).href).pathname) const href = props.href || ""
props.onClick?.(e) if (e.ctrlKey || e.metaKey) {
window.open(href, "_blank")
} else {
$router.open(href)
props.onClick?.(e)
}
}} }}
></a> ></a>
) )