mirror of
https://github.com/thegeeklab/hugo-geekdoc.git
synced 2024-11-22 04:40:40 +00:00
feat: add site parameter geekdocFileTreeSortBy
to controle filetree menu sorting (#237)
This commit is contained in:
parent
2e2d1549ab
commit
761caeee47
@ -106,6 +106,11 @@ enableRobotsTXT = true
|
|||||||
|
|
||||||
# (Optional, default false) Enable or disable adding tags for post pages automatically to the navigation sidebar.
|
# (Optional, default false) Enable or disable adding tags for post pages automatically to the navigation sidebar.
|
||||||
geekdocTagsToMenu = true
|
geekdocTagsToMenu = true
|
||||||
|
|
||||||
|
# (Optional, default 'title') Configure how to sort file-tree menu entries. Possible options are 'title', 'linktitle',
|
||||||
|
# 'date', 'publishdate', 'expirydate' or 'lastmod'. Every option can be used with a reverse modifier as well
|
||||||
|
# e.g. 'title_reverse'.
|
||||||
|
geekdocFileTreeSortBy = "title"
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
@ -214,6 +219,11 @@ params:
|
|||||||
|
|
||||||
# (Optional, default false) Enable or disable adding tags for post pages automatically to the navigation sidebar.
|
# (Optional, default false) Enable or disable adding tags for post pages automatically to the navigation sidebar.
|
||||||
geekdocTagsToMenu: true
|
geekdocTagsToMenu: true
|
||||||
|
|
||||||
|
# (Optional, default 'title') Configure how to sort file-tree menu entries. Possible options are 'title', 'linktitle',
|
||||||
|
# 'date', 'publishdate', 'expirydate' or 'lastmod'. Every option can be used with a reverse modifier as well
|
||||||
|
# e.g. 'title_reverse'.
|
||||||
|
geekdocFileTreeSortBy: "title"
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
|
@ -6,8 +6,37 @@
|
|||||||
{{ $current := .current }}
|
{{ $current := .current }}
|
||||||
|
|
||||||
<ul class="gdoc-nav__list">
|
<ul class="gdoc-nav__list">
|
||||||
|
{{ $sortBy := (default "title" .current.Site.Params.GeekdocFileTreeSortBy | lower) }}
|
||||||
{{ range .sect.GroupBy "Weight" }}
|
{{ range .sect.GroupBy "Weight" }}
|
||||||
{{ range .ByTitle }}
|
{{ $rangeBy := .ByTitle }}
|
||||||
|
|
||||||
|
{{ if eq $sortBy "title" }}
|
||||||
|
{{ $rangeBy = .ByTitle }}
|
||||||
|
{{ else if eq $sortBy "linktitle" }}
|
||||||
|
{{ $rangeBy = .ByLinkTitle }}
|
||||||
|
{{ else if eq $sortBy "date" }}
|
||||||
|
{{ $rangeBy = .ByDate }}
|
||||||
|
{{ else if eq $sortBy "publishdate" }}
|
||||||
|
{{ $rangeBy = .ByPublishDate }}
|
||||||
|
{{ else if eq $sortBy "expirydate" }}
|
||||||
|
{{ $rangeBy = .ByExpiryDate }}
|
||||||
|
{{ else if eq $sortBy "lastmod" }}
|
||||||
|
{{ $rangeBy = .ByLastmod }}
|
||||||
|
{{ else if eq $sortBy "title_reverse" }}
|
||||||
|
{{ $rangeBy = .ByTitle.Reverse }}
|
||||||
|
{{ else if eq $sortBy "linktitle_reverse" }}
|
||||||
|
{{ $rangeBy = .ByLinkTitle.Reverse }}
|
||||||
|
{{ else if eq $sortBy "date_reverse" }}
|
||||||
|
{{ $rangeBy = .ByDate.Reverse }}
|
||||||
|
{{ else if eq $sortBy "publishdate_reverse" }}
|
||||||
|
{{ $rangeBy = .ByPublishDate.Reverse }}
|
||||||
|
{{ else if eq $sortBy "expirydate_reverse" }}
|
||||||
|
{{ $rangeBy = .ByExpiryDate.Reverse }}
|
||||||
|
{{ else if eq $sortBy "lastmod_reverse" }}
|
||||||
|
{{ $rangeBy = .ByLastmod.Reverse }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range $rangeBy }}
|
||||||
{{ if not .Params.GeekdocHidden }}
|
{{ if not .Params.GeekdocHidden }}
|
||||||
|
|
||||||
{{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
|
{{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user