Skip to content

Can the default header level be changed? #1742

Answered by nobkd
tomleo asked this question in Q&A
Discussion options

You must be logged in to vote

Sure. you can create the component components/content/ProseH1.vue (used by the parser to convert # to <h1>) to override the internal ProseH1 component, so it displays a <h2> instead of a <h1>.

e.g. just for title generation:

<!-- /components/content/ProseH1.vue -->

<template>
  <h2><slot /></h2>
</template>

or with title and link generation:

<!-- /components/content/ProseH1.vue -->

<template>
  <h2 :id="id">
    <a :href="`#${id}`">
      <slot />
    </a>
  </h2>
</template>

<script setup lang="ts">
defineProps<{ id: string }>()
</script>

If you want to, you can repeat this process for the ProseH2 to ProseH5 in the same way (remember that you have h6 two times then)

Refer to the prose…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tomleo
Comment options

Answer selected by tomleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants