mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
hugolib: Add ability to sort by frontmatter parameters
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
2618cfbeaa
commit
298ebc37c2
@@ -237,6 +237,18 @@ your list templates:
|
||||
</li>
|
||||
{{ end }}
|
||||
|
||||
### Order by Parameter
|
||||
Order based on the specified frontmatter parameter. Pages without that
|
||||
parameter will use the site's `.Site.Params` default. If the parameter is not
|
||||
found at all in some entries, those entries will appear together at the end
|
||||
of the ordering.
|
||||
|
||||
The below example sorts a list of posts by their rating.
|
||||
|
||||
{{ range (.Data.Pages.ByParam "rating") }}
|
||||
<!-- ... -->
|
||||
{{ end }}
|
||||
|
||||
### Reverse Order
|
||||
Can be applied to any of the above. Using Date for an example.
|
||||
|
||||
|
Reference in New Issue
Block a user