Skip to content

Commit

Permalink
Add JS for the hashtag section (#644)
Browse files Browse the repository at this point in the history
* Lets try this again

* Add JS to handle hashtags
  • Loading branch information
javisperez authored Dec 4, 2024
1 parent 1552ed1 commit ccf0e62
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions docs/.vitepress/theme/components/Home.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { isClient } from '@vueuse/core'
import { ref, computed } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { Vue3Marquee } from 'vue3-marquee'
import Accordion from './Accordion.vue'
import vGaTrack from '../directives/ga'
import axios, { type AxiosError } from 'axios'
import axios from 'axios'
import VueTurnstile from 'vue-turnstile'
const error = ref('')
Expand Down Expand Up @@ -91,6 +91,21 @@ const subscribeToNewsletter = async () => {
isBusy.value = false
}
}
onMounted(() => {
setTimeout(() => {
// check if there's an anchor link in the url and if so, scroll to that element id
if (location.hash) {
const el = document.querySelector(location.hash)
if (el && el instanceof HTMLElement) {
el.scrollIntoView({
behavior:'smooth',
block: 'center',
})
}
}
}, 100)
})
</script>

<template>
Expand Down

0 comments on commit ccf0e62

Please sign in to comment.