Skip to content

Commit a0641b1

Browse files
committed
fix: strange anchor behavior in Chrome
1 parent 3d275eb commit a0641b1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/router.options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { useScrollStore } from '~/stores/scroll';
44
export default <RouterConfig>{
55
scrollBehavior(to, _from, savedPosition) {
66
if (savedPosition) return savedPosition;
7-
if (to.hash) useScrollStore().scrollOrSet(to.hash);
7+
else if (to.hash) useScrollStore().scrollOrSet(to.hash);
88
}
99
};

components/content/ProseH2.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<h2 :id="props.id">
3-
<a
3+
<AppLink
44
v-if="props.id && generate"
5-
:href="`#${props.id}`"
5+
:to="`${$route.path}#${props.id}`"
66
>
77
<slot mdc-unwrap="p" />
8-
</a>
8+
</AppLink>
99
<slot v-else />
1010
</h2>
1111
</template>
@@ -17,4 +17,4 @@ const props = defineProps<{ id?: string }>()
1717
1818
const { headings } = useRuntimeConfig().public.mdc
1919
const generate = computed(() => props.id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h2)))
20-
</script>
20+
</script>

0 commit comments

Comments
 (0)