From e3f8fc7972f5506cd9def08ad13c62141737318f Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:16:38 +0530 Subject: [PATCH] fix(theme): allow using h1 headings in outline closes #1529 --- __tests__/e2e/frontmatter/multiple-levels-outline.md | 2 +- src/client/theme-default/composables/outline.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/__tests__/e2e/frontmatter/multiple-levels-outline.md b/__tests__/e2e/frontmatter/multiple-levels-outline.md index 332a7cda65db..09a1740691dd 100644 --- a/__tests__/e2e/frontmatter/multiple-levels-outline.md +++ b/__tests__/e2e/frontmatter/multiple-levels-outline.md @@ -1,7 +1,7 @@ --- title: Multiple Levels Outline editLink: true -outline: 'deep' +outline: deep --- # h1 - 1 diff --git a/src/client/theme-default/composables/outline.ts b/src/client/theme-default/composables/outline.ts index c59234cbefce..666896ebf53d 100644 --- a/src/client/theme-default/composables/outline.ts +++ b/src/client/theme-default/composables/outline.ts @@ -22,7 +22,9 @@ export function resolveTitle(theme: DefaultTheme.Config) { } export function getHeaders(range: DefaultTheme.Config['outline']) { - const headers = [...document.querySelectorAll('.VPDoc h2,h3,h4,h5,h6')] + const headers = [ + ...document.querySelectorAll('.VPDoc :where(h1,h2,h3,h4,h5,h6)') + ] .filter((el) => el.id && el.hasChildNodes()) .map((el) => { const level = Number(el.tagName[1])