From 20386a883eea8f088a469d34a629416fd822cb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 11:21:52 +0800 Subject: [PATCH 1/7] fix sidebar: auto bug --- lib/default-theme/util.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/default-theme/util.js b/lib/default-theme/util.js index 5aafb431bb..5017e1703f 100644 --- a/lib/default-theme/util.js +++ b/lib/default-theme/util.js @@ -105,10 +105,6 @@ function resolvePath (relative, base, append) { } export function resolveSidebarItems (page, route, site, localePath) { - const pageSidebarConfig = page.frontmatter.sidebar - if (pageSidebarConfig === 'auto') { - return resolveHeaders(page) - } const { pages, themeConfig } = site const localeConfig = localePath && themeConfig.locales From 6a8d7804f73e02bc2a2d153de2787cd232023b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 11:24:13 +0800 Subject: [PATCH 2/7] Update util.js --- lib/default-theme/util.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/default-theme/util.js b/lib/default-theme/util.js index 5017e1703f..4d484507f7 100644 --- a/lib/default-theme/util.js +++ b/lib/default-theme/util.js @@ -122,22 +122,6 @@ export function resolveSidebarItems (page, route, site, localePath) { } } -function resolveHeaders (page) { - const headers = groupHeaders(page.headers || []) - return [{ - type: 'group', - collapsable: false, - title: page.title, - children: headers.map(h => ({ - type: 'auto', - title: h.title, - basePath: page.path, - path: page.path + '#' + h.slug, - children: h.children || [] - })) - }] -} - export function groupHeaders (headers) { // group h3s under h2 headers = headers.map(h => Object.assign({}, h)) From 21d13717109fb8ebee6fd18bceb202da12bf9104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 11:25:03 +0800 Subject: [PATCH 3/7] Update SidebarLink.vue --- lib/default-theme/SidebarLink.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/default-theme/SidebarLink.vue b/lib/default-theme/SidebarLink.vue index 894aeaff41..a8935f0393 100644 --- a/lib/default-theme/SidebarLink.vue +++ b/lib/default-theme/SidebarLink.vue @@ -19,7 +19,7 @@ export default { : $site.themeConfig.sidebarDepth const maxDepth = configDepth == null ? 1 : configDepth if (item.type === 'auto') { - return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)] + return [link, renderChildren(h, item.children, item.basePath, $route, 3)] } else if (active && item.headers && !hashRE.test(item.path)) { const children = groupHeaders(item.headers) return [link, renderChildren(h, children, item.path, $route, maxDepth)] From 68587e65453002332752acac59c98917c55cb419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 11:56:14 +0800 Subject: [PATCH 4/7] Update SidebarLink.vue --- lib/default-theme/SidebarLink.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/default-theme/SidebarLink.vue b/lib/default-theme/SidebarLink.vue index a8935f0393..703e37dded 100644 --- a/lib/default-theme/SidebarLink.vue +++ b/lib/default-theme/SidebarLink.vue @@ -18,8 +18,14 @@ export default { ? $page.frontmatter.sidebarDepth : $site.themeConfig.sidebarDepth const maxDepth = configDepth == null ? 1 : configDepth + + if (item.frontmatter.sidebar === 'auto') { + const children = groupHeaders(item.headers) + return [link, renderChildren(h, children, item.path, $route, maxDepth)] + } + if (item.type === 'auto') { - return [link, renderChildren(h, item.children, item.basePath, $route, 3)] + return [link, renderChildren(h, item.children, item.basePath, $route, macDepth)] } else if (active && item.headers && !hashRE.test(item.path)) { const children = groupHeaders(item.headers) return [link, renderChildren(h, children, item.path, $route, maxDepth)] From c906b642f075ba40b35e44eb85ab5c6fff93251a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 11:56:56 +0800 Subject: [PATCH 5/7] Update SidebarLink.vue --- lib/default-theme/SidebarLink.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/default-theme/SidebarLink.vue b/lib/default-theme/SidebarLink.vue index 703e37dded..1cb66cc700 100644 --- a/lib/default-theme/SidebarLink.vue +++ b/lib/default-theme/SidebarLink.vue @@ -25,7 +25,7 @@ export default { } if (item.type === 'auto') { - return [link, renderChildren(h, item.children, item.basePath, $route, macDepth)] + return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)] } else if (active && item.headers && !hashRE.test(item.path)) { const children = groupHeaders(item.headers) return [link, renderChildren(h, children, item.path, $route, maxDepth)] From 7ca4da570762de74495a39248ed8de36d6ebc940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 13:48:43 +0800 Subject: [PATCH 6/7] Update SidebarLink.vue --- lib/default-theme/SidebarLink.vue | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/default-theme/SidebarLink.vue b/lib/default-theme/SidebarLink.vue index 1cb66cc700..0212f4caee 100644 --- a/lib/default-theme/SidebarLink.vue +++ b/lib/default-theme/SidebarLink.vue @@ -19,16 +19,11 @@ export default { : $site.themeConfig.sidebarDepth const maxDepth = configDepth == null ? 1 : configDepth - if (item.frontmatter.sidebar === 'auto') { - const children = groupHeaders(item.headers) - return [link, renderChildren(h, children, item.path, $route, maxDepth)] - } - if (item.type === 'auto') { return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)] } else if (active && item.headers && !hashRE.test(item.path)) { const children = groupHeaders(item.headers) - return [link, renderChildren(h, children, item.path, $route, maxDepth)] + return item.frontmatter.sidebar === 'auto' ? [link, renderChildren(h, children, item.path, $route, 3)] : [link, renderChildren(h, children, item.path, $route, maxDepth)] } else { return link } From 87c8d5a34150055919d37cc308c892591f388793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=BA=A2?= Date: Wed, 2 May 2018 13:49:06 +0800 Subject: [PATCH 7/7] Update SidebarLink.vue --- lib/default-theme/SidebarLink.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/default-theme/SidebarLink.vue b/lib/default-theme/SidebarLink.vue index 0212f4caee..33bef305e8 100644 --- a/lib/default-theme/SidebarLink.vue +++ b/lib/default-theme/SidebarLink.vue @@ -18,7 +18,6 @@ export default { ? $page.frontmatter.sidebarDepth : $site.themeConfig.sidebarDepth const maxDepth = configDepth == null ? 1 : configDepth - if (item.type === 'auto') { return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)] } else if (active && item.headers && !hashRE.test(item.path)) {