[Vuejs]-Why are H1 tags excluded from NuxtJS's Content module's TOC list?

0👍

Was looking in the wrong place.

I managed to add H1 tags to the TOC list by changing the content/lib/utils.js file.

  const { tocDepth } = markdown
  const tocTags = []

  if (tocDepth < 1) {
    logger.info(`content.markdown.tocDepth is set as ${tocDepth}. Table of contents of markdown files will be empty.`)
    return tocTags
  }

  if (tocDepth > 6) {
    logger.info(`content.markdown.tocDepth is set as ${tocDepth}. Table of contents of markdown files will include all the headings.`)
  }


  // CHANGE LINE BELOW FROM i=2 to i=1

  for (let i = 1; i <= tocDepth; i++) {
    tocTags.push(`h${i}`)
  }

  return tocTags
}

Couldn’t find anything on the web that related to this question, so hope this helps someone!

Leave a comment