GroupByParam
返回给定页面集合按给定参数升序分组。
Syntax
PAGES.GroupByParam PARAM [SORT]
Returns
page.PagesGroup
对于可选排序顺序,指定 asc 表示升序,或 desc 表示降序。
{{ range .Pages.GroupByParam "color" }}
<p>{{ .Key | title }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}要按降序对组排序:
{{ range .Pages.GroupByParam "color" "desc" }}
<p>{{ .Key | title }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}