Skip to content

Commit 3572c1e

Browse files
committed
sort components by name instead of title
1 parent 9fd5562 commit 3572c1e

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

antora.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: _
22
version: ~
33
title: fuquery
4+
index: 0
5+
extra:
6+
index: 1
47
nav:
58
- modules/ROOT/nav.adoc

ui/helpers/sort-by.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict'
2+
3+
module.exports = (collection, field = 'name') => {
4+
if (!collection) return []
5+
6+
let arr = []
7+
8+
if (Array.isArray(collection)) {
9+
arr = collection.slice()
10+
} else if (typeof collection === 'object') {
11+
arr = Object.keys(collection).map(key => collection[key])
12+
} else {
13+
return []
14+
}
15+
16+
arr.sort((a, b) => {
17+
const va = (a[field] || '').toString().toLowerCase()
18+
const vb = (b[field] || '').toString().toLowerCase()
19+
return va < vb ? -1 : va > vb ? 1 : 0
20+
})
21+
22+
return arr
23+
}

ui/partials/nav-explore.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
{{/if}}
88
<ul class="components">
9-
{{#each site.components}}
9+
{{#each (sort-by site.components 'name')}}
1010
<li class="component{{#if (eq this @root.page.component)}} is-current{{/if}}">
1111
<div class="title"><a href="{{{relativize ./url}}}">{{{./title}}}</a></div>
1212
{{#if (or ./versions.[1] ./versions.[0].version (ne ./versions.[0].displayVersion 'default'))}}

0 commit comments

Comments
 (0)