mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-09-27 11:06:41 -05:00
fix: requested changes
This commit is contained in:
19
src/components/MdLink.vue
Normal file
19
src/components/MdLink.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script lang="ts" setup>
|
||||
function fixFragmentLinks(e: MouseEvent) {
|
||||
const targetEl = e.target as HTMLAnchorElement;
|
||||
const to = targetEl?.getAttribute('href');
|
||||
|
||||
if (targetEl?.tagName !== 'A' || !to?.startsWith('#')) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
document.getElementById(to.slice(1))?.scrollTo();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtLink @click="fixFragmentLinks">
|
||||
<slot />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
Reference in New Issue
Block a user