mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 02:16:09 +00:00
hugolib: Add ability to sort by frontmatter parameters
This commit is contained in:
1 parent
6693e6c53e
commit
435bb858de
1 file changed
+12
@@ -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