hugolib: Add ability to sort by frontmatter parameters

This commit is contained in:
John Feminella
2017-02-10 08:01:25 -05:00
committed by Bjørn Erik Pedersen
parent 2618cfbeaa
commit 298ebc37c2
3 changed files with 71 additions and 0 deletions

View File

@@ -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.