From 597f83b8adc92ae777571009067e37ba6fcc0e36 Mon Sep 17 00:00:00 2001 From: Robert Lin Date: Sun, 14 Jun 2020 20:27:55 +0800 Subject: [PATCH] feat($theme-default): allow 'auto' in defined sidebars (close: #1252) (#2380) --- packages/@vuepress/theme-default/util/index.js | 3 +++ packages/docs/docs/theme/default-theme-config.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/packages/@vuepress/theme-default/util/index.js b/packages/@vuepress/theme-default/util/index.js index 23e78f83c1..4433bb3c5f 100644 --- a/packages/@vuepress/theme-default/util/index.js +++ b/packages/@vuepress/theme-default/util/index.js @@ -138,6 +138,9 @@ export function resolveSidebarItems (page, regularPath, site, localePath) { return [] } else { const { base, config } = resolveMatchingConfig(regularPath, sidebarConfig) + if (config === 'auto') { + return resolveHeaders(page) + } return config ? config.map(item => resolveItem(item, pages, base)) : [] diff --git a/packages/docs/docs/theme/default-theme-config.md b/packages/docs/docs/theme/default-theme-config.md index 03b5ef7734..84cb68fefc 100644 --- a/packages/docs/docs/theme/default-theme-config.md +++ b/packages/docs/docs/theme/default-theme-config.md @@ -273,6 +273,8 @@ module.exports = { 'four' /* /bar/four.html */ ], + '/baz/': 'auto', /* automatically generate single-page sidebars */ + // fallback '/': [ '', /* / */