diff options
author | 2022-01-24 23:33:56 +0800 | |
---|---|---|
committer | 2022-01-24 10:33:56 -0500 | |
commit | 20dc304172f8d5d6b289ea4b34b64684fb612836 (patch) | |
tree | d0ec2c101893c9575857f8848f5f4d83a500dbea /examples/docs/src | |
parent | 1f45d23103f96fce595366e8c1a9278991b7118f (diff) | |
download | astro-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.astro | 9 |
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 { |