Skip to content
Snippets Groups Projects
Commit 9e785658 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

anchor take into account navbar height

parent c97f8f13
No related branches found
No related tags found
No related merge requests found
<template> <template>
<h1 class="text-h3 font-weight-bold" :id="id"> <span :id="id" class="anchor"></span>
<h1 class="text-h3 font-weight-bold my-6">
<a v-if="id && generate" :href="`#${id}`" class="text-decoration-none"> <a v-if="id && generate" :href="`#${id}`" class="text-decoration-none">
<slot /> <slot />
</a> </a>
...@@ -21,4 +22,10 @@ const generate = ...@@ -21,4 +22,10 @@ const generate =
a { a {
color: inherit; color: inherit;
} }
anchor {
display: block;
position: relative;
top: -64px;
visibility: hidden;
}
</style> </style>
<template> <template>
<h2 class="text-h4 font-weight-bold" :id="id"> <span :id="id" class="anchor"></span>
<h2 class="text-h4 font-weight-bold my-4">
<a v-if="id && generate" :href="`#${id}`" class="text-decoration-none"> <a v-if="id && generate" :href="`#${id}`" class="text-decoration-none">
<slot /> <slot />
</a> </a>
...@@ -19,4 +20,10 @@ const generate = ...@@ -19,4 +20,10 @@ const generate =
a { a {
color: inherit; color: inherit;
} }
.anchor {
display: block;
position: relative;
top: -64px;
visibility: hidden;
}
</style> </style>
<template>
<span :id="id" class="anchor"></span>
<h3 class="text-h6 font-weight-bold my-3">
<a v-if="id && generate" :href="`#${id}`" class="text-decoration-none">
<slot />
</a>
<slot v-else />
</h3>
</template>
<script setup lang="ts">
import { useRuntimeConfig } from "#imports";
defineProps<{ id?: string }>();
const heading = 3;
const { anchorLinks } = useRuntimeConfig().public.content;
const generate =
anchorLinks?.depth >= heading && !anchorLinks?.exclude.includes(heading);
</script>
<style scoped>
a {
color: inherit;
}
.anchor {
display: block;
position: relative;
top: -64px;
visibility: hidden;
}
</style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment