aboutsummaryrefslogtreecommitdiff
path: root/examples/docs/src
diff options
context:
space:
mode:
authorGravatar Jang Rush <weakish@gmail.com> 2022-01-24 23:33:56 +0800
committerGravatar GitHub <noreply@github.com> 2022-01-24 10:33:56 -0500
commit20dc304172f8d5d6b289ea4b34b64684fb612836 (patch)
treed0ec2c101893c9575857f8848f5f4d83a500dbea /examples/docs/src
parent1f45d23103f96fce595366e8c1a9278991b7118f (diff)
downloadastro-20dc304172f8d5d6b289ea4b34b64684fb612836.tar.gz
astro-20dc304172f8d5d6b289ea4b34b64684fb612836.tar.zst
astro-20dc304172f8d5d6b289ea4b34b64684fb612836.zip
Allow not specfying section header in sidebar. (#2448)
Someone may forget to specify a section header in SIDEBAR, which would cause build error previously.
Diffstat (limited to 'examples/docs/src')
-rw-r--r--examples/docs/src/components/LeftSidebar/LeftSidebar.astro9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/docs/src/components/LeftSidebar/LeftSidebar.astro b/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
index dd7b34e0f..99a03213d 100644
--- a/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
+++ b/examples/docs/src/components/LeftSidebar/LeftSidebar.astro
@@ -5,7 +5,14 @@ const { currentPage } = Astro.props;
const currentPageMatch = currentPage.slice(1);
const langCode = getLanguageFromURL(currentPage);
// SIDEBAR is a flat array. Group it by sections to properly render.
-const sidebarSections = SIDEBAR[langCode].reduce((col, item) => {
+const sidebarSections = SIDEBAR[langCode].reduce((col, item, i) => {
+ // If the first item is not a section header, create a new container section.
+ if (i === 0) {
+ if (!item.header) {
+ const pesudoSection = { text: "" };
+ col.push({ ...pesudoSection, children: [] });
+ }
+ }
if (item.header) {
col.push({ ...item, children: [] });
} else {