Files
estel_docs/app/components/content/ProseH2.vue
2025-07-29 00:32:57 +08:00

22 lines
621 B
Vue

<template>
<h2
:id
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors [&:not(:first-child)]:mt-10"
>
<NuxtLink
v-if="id && generate"
:to="`#${id}`"
>
<slot />
</NuxtLink>
<slot v-else />
</h2>
</template>
<script setup lang="ts">
const { id } = defineProps<{ id?: string }>()
const { headings } = useRuntimeConfig().public.mdc
const generate = computed(() => id && ((typeof headings?.anchorLinks === 'boolean' && headings?.anchorLinks === true) || (typeof headings?.anchorLinks === 'object' && headings?.anchorLinks?.h2)))
</script>