Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -1,26 +1,21 @@
---
title: collections.Group
linkTitle: group
description: Groups a list of pages.
categories: [functions]
description: Groups the given page collection by the given key.
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [group]
related:
- functions/collections/Dictionary
- functions/collections/IndexFunction
- functions/collections/IsSet
- functions/collections/Where
returnType: any
signatures: [PAGES | collections.Group KEY]
relatedFunctions:
- collections.Dictionary
- collections.Group
- collections.Index
- collections.IsSet
- collections.Where
signatures: [collections.Group KEY PAGES]
aliases: [/functions/group]
---
{{< code file="layouts/partials/groups.html" >}}
```go-html-template
{{ $new := .Site.RegularPages | first 10 | group "New" }}
{{ $old := .Site.RegularPages | last 10 | group "Old" }}
{{ $groups := slice $new $old }}
@@ -29,12 +24,12 @@ aliases: [/functions/group]
<ul>
{{ range .Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
</ul>
{{ end }}
{{< /code >}}
```
The page group you get from `group` is of the same type you get from the built-in [group methods](/templates/lists#group-content) in Hugo. The above example can be [paginated](/templates/pagination/#list-paginator-pages).