Files
takerofnotes-website/components/Link.vue
2026-03-17 23:07:22 -04:00

28 lines
561 B
Vue

<template>
<a :class="{ active: isActive }">
<slot />
</a>
</template>
<script lang="ts" setup>
import { usePageContext } from 'vike-vue/usePageContext'
import { computed, useAttrs } from 'vue'
const pageContext = usePageContext()
const { href } = useAttrs()
const isActive = computed(() => {
const { urlPathname } = pageContext
return href === '/' ? urlPathname === href : urlPathname.startsWith(href)
})
</script>
<style scoped>
a {
padding: 2px 10px;
margin-left: -10px;
}
a.active {
background-color: #eee;
}
</style>