Skip to content

Commit

Permalink
Merge pull request #943 from flowforge/leftnav-options
Browse files Browse the repository at this point in the history
Redirect support for group index & navOrder to control left nav option
  • Loading branch information
ZJvandeWeg authored Jul 8, 2023
2 parents 36bccca + ab3315a commit da4a68d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ module.exports = function(eleventyConfig) {
if (!accumulator[currentValue]) {
accumulator[currentValue] = {
'name': currentValue,
'url': page.url,
'url': page.data.redirect || page.url,
'order': page.data.navOrder || Number.MAX_SAFE_INTEGER,
'children': {}
}
if (page.data.navTitle) {
Expand Down Expand Up @@ -413,7 +414,7 @@ module.exports = function(eleventyConfig) {
let groups = {
'Other': {
name: 'Other',
order: -1, // always render last
order: Number.MAX_SAFE_INTEGER, // always render last
children: []
}
}
Expand All @@ -439,7 +440,7 @@ module.exports = function(eleventyConfig) {

function sortChildren (a, b) {
// sort children by 'order', then alphabetical
return b.order - a.order || a.name.localeCompare(b.name)
return (a.order - b.order) || a.name.localeCompare(b.name)
}

nav[tag].groups = Object.values(groups).sort(sortChildren)
Expand Down

0 comments on commit da4a68d

Please sign in to comment.