Allow not specfying section header in sidebar. (#2448)
Someone may forget to specify a section header in SIDEBAR, which would cause build error previously.
This commit is contained in:
parent
1f45d23103
commit
20dc304172
1 changed files with 8 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue