|
|
@ -153,9 +153,21 @@ export function createRouter(
|
|
|
|
const button = (e.target as Element).closest('button')
|
|
|
|
const button = (e.target as Element).closest('button')
|
|
|
|
if (button) return
|
|
|
|
if (button) return
|
|
|
|
|
|
|
|
|
|
|
|
const link = (e.target as Element).closest('a')
|
|
|
|
const link = (e.target as Element | SVGElement).closest<
|
|
|
|
if (link && !link.closest('.vp-raw') && !link.download) {
|
|
|
|
HTMLAnchorElement | SVGAElement
|
|
|
|
const { href, origin, pathname, hash, search, target } = link
|
|
|
|
>('a')
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
link &&
|
|
|
|
|
|
|
|
!link.closest('.vp-raw') &&
|
|
|
|
|
|
|
|
(link instanceof SVGElement || !link.download)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
const { target } = link
|
|
|
|
|
|
|
|
const { href, origin, pathname, hash, search } = new URL(
|
|
|
|
|
|
|
|
link.href instanceof SVGAnimatedString
|
|
|
|
|
|
|
|
? link.href.animVal
|
|
|
|
|
|
|
|
: link.href,
|
|
|
|
|
|
|
|
link.baseURI
|
|
|
|
|
|
|
|
)
|
|
|
|
const currentUrl = window.location
|
|
|
|
const currentUrl = window.location
|
|
|
|
const extMatch = pathname.match(/\.\w+$/)
|
|
|
|
const extMatch = pathname.match(/\.\w+$/)
|
|
|
|
// only intercept inbound links
|
|
|
|
// only intercept inbound links
|
|
|
@ -217,8 +229,8 @@ export function useRoute(): Route {
|
|
|
|
return useRouter().route
|
|
|
|
return useRouter().route
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function scrollTo(el: HTMLElement, hash: string, smooth = false) {
|
|
|
|
function scrollTo(el: HTMLElement | SVGElement, hash: string, smooth = false) {
|
|
|
|
let target: HTMLElement | null = null
|
|
|
|
let target: HTMLElement | SVGElement | null = null
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
target = el.classList.contains('header-anchor')
|
|
|
|
target = el.classList.contains('header-anchor')
|
|
|
|