Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'

This commit is contained in:
Bjørn Erik Pedersen
2024-06-21 09:41:24 +02:00
475 changed files with 7408 additions and 4720 deletions

View File

@@ -0,0 +1,44 @@
---
title: First
description: Returns the first pager in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/Last
- methods/pager/Prev
- methods/pager/Next
- methods/pager/HasPrev
- methods/pager/HasNext
- methods/page/Paginate
returnType: page.Pager
signatures: [PAGER.First]
---
Use the `First` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,72 @@
---
title: HasNext
description: Reports whether there is a pager after the current pager.
categories: []
keywords: []
action:
related:
- methods/pager/HasPrev
- methods/pager/Prev
- methods/pager/Next
- methods/pager/First
- methods/pager/Last
- methods/page/Paginate
returnType: bool
signatures: [PAGER.HasNext]
---
Use the `HasNext` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ if .HasPrev }}
<li><a href="{{ .Prev.URL }}">Previous</a></li>
{{ end }}
{{ if .HasNext }}
<li><a href="{{ .Next.URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```
You can also write the above without using the `HasNext` method:
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,72 @@
---
title: HasPrev
description: Reports whether there is a pager before the current pager.
categories: []
keywords: []
action:
related:
- methods/pager/HasNext
- methods/pager/Prev
- methods/pager/Next
- methods/pager/First
- methods/pager/Last
- methods/page/Paginate
returnType: bool
signatures: [PAGER.HasPrev]
---
Use the `HasPrev` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ if .HasPrev }}
<li><a href="{{ .Prev.URL }}">Previous</a></li>
{{ end }}
{{ if .HasNext }}
<li><a href="{{ .Next.URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```
You can also write the above without using the `HasPrev` method:
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,44 @@
---
title: Last
description: Returns the last pager in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/First
- methods/pager/Prev
- methods/pager/Next
- methods/pager/HasPrev
- methods/pager/HasNext
- methods/page/Paginate
returnType: page.Pager
signatures: [PAGER.Last]
---
Use the `Last` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,44 @@
---
title: Next
description: Returns the next pager in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/Prev
- methods/pager/HasPrev
- methods/pager/HasNext
- methods/pager/First
- methods/pager/Last
- methods/page/Paginate
returnType: page.Pager
signatures: [PAGER.Next]
---
Use the `Next` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,25 @@
---
title: NumberOfElements
description: Returns the number of pages in the current pager.
categories: []
keywords: []
action:
related:
- methods/pager/TotalNumberOfElements
- methods/page/Paginate
returnType: int
signatures: [PAGER.NumberOfElements]
---
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
{{ .NumberOfElements }}
{{ end }}
```

View File

@@ -0,0 +1,29 @@
---
title: PageGroups
description: Returns the page groups in the current pager.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
returnType: page.PagesGroup
signatures: [PAGER.PageGroups]
---
Use the `PageGroups` method with any of the [grouping methods].
[grouping methods]: /quick-reference/page-collections/#group
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate ($pages.GroupByDate "Jan 2006") }}
{{ range $paginator.PageGroups }}
<h2>{{ .Key }}</h2>
{{ range .Pages }}
<h3><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h3>
{{ end }}
{{ end }}
{{ template "_internal/pagination.html" . }}
```

View File

@@ -0,0 +1,31 @@
---
title: PageNumber
description: Returns the current pager's number within the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/TotalPages
- methods/page/Paginate
returnType: int
signatures: [PAGER.PageNumber]
---
Use the `PageNumber` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ range .Pagers }}
<li><a href="{{ .URL }}">{{ .PageNumber }}</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,24 @@
---
title: PageSize
description: Returns the maximum number of pages per pager.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
returnType: int
signatures: [PAGER.PageSize]
---
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
{{ .PageSize }}
{{ end }}
```

View File

@@ -0,0 +1,30 @@
---
title: Pagers
description: Returns the pagers collection.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
returnType: page.pagers
signatures: [PAGER.Pagers]
---
Use the `Pagers` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ range .Pagers }}
<li><a href="{{ .URL }}">{{ .PageNumber }}</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,22 @@
---
title: Pages
description: Returns the pages in the current pager.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
returnType: page.Pages
signatures: [PAGER.Pages]
---
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ template "_internal/pagination.html" . }}
```

View File

@@ -0,0 +1,44 @@
---
title: Prev
description: Returns the previous pager in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/Next
- methods/pager/HasPrev
- methods/pager/HasNext
- methods/pager/First
- methods/pager/Last
- methods/page/Paginate
returnType: page.Pager
signatures: [PAGER.Prev]
---
Use the `Prev` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,25 @@
---
title: TotalNumberOfElements
description: Returns the number of pages in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/NumberOfElements
- methods/page/Paginate
returnType: int
signatures: [PAGER.TotalNumberOfElements]
---
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
{{ .TotalNumberOfElements }}
{{ end }}
```

View File

@@ -0,0 +1,41 @@
---
title: TotalPages
description: Returns the number of pagers in the pager collection.
categories: []
keywords: []
action:
related:
- methods/pager/PageNumber
- methods/page/Paginate
returnType: int
signatures: [PAGER.TotalPages]
---
Use the `TotalPages` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<p>Pager {{ .PageNumber }} of {{ .TotalPages }}</p>
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,39 @@
---
title: URL
description: Returns the URL of the current pager relative to the site root.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
returnType: string
signatures: [PAGER.URL]
---
Use the `URL` method to build navigation between pagers.
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
<ul>
{{ with .First }}
<li><a href="{{ .URL }}">First</a></li>
{{ end }}
{{ with .Prev }}
<li><a href="{{ .URL }}">Previous</a></li>
{{ end }}
{{ with .Next }}
<li><a href="{{ .URL }}">Next</a></li>
{{ end }}
{{ with .Last }}
<li><a href="{{ .URL }}">Last</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,14 @@
---
title: Pager methods
linkTitle: Pager
description: Use these methods with Pager objects when paginating a list page.
keywords: []
menu:
docs:
identifier:
parent: methods
---
Use these methods with Pager objects when building navigation for a [paginated] list page.
[paginated]: /templates/pagination/