HUGO
Menu
GitHub 87548 stars Mastodon

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 }}

Last updated: January 1, 0001
Improve this page