summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/pager
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/methods/pager')
-rw-r--r--docs/content/en/methods/pager/First.md44
-rw-r--r--docs/content/en/methods/pager/HasNext.md72
-rw-r--r--docs/content/en/methods/pager/HasPrev.md72
-rw-r--r--docs/content/en/methods/pager/Last.md44
-rw-r--r--docs/content/en/methods/pager/Next.md44
-rw-r--r--docs/content/en/methods/pager/NumberOfElements.md25
-rw-r--r--docs/content/en/methods/pager/PageGroups.md29
-rw-r--r--docs/content/en/methods/pager/PageNumber.md31
-rw-r--r--docs/content/en/methods/pager/PageSize.md24
-rw-r--r--docs/content/en/methods/pager/Pagers.md30
-rw-r--r--docs/content/en/methods/pager/Pages.md22
-rw-r--r--docs/content/en/methods/pager/Prev.md44
-rw-r--r--docs/content/en/methods/pager/TotalNumberOfElements.md25
-rw-r--r--docs/content/en/methods/pager/TotalPages.md41
-rw-r--r--docs/content/en/methods/pager/URL.md39
-rw-r--r--docs/content/en/methods/pager/_index.md14
16 files changed, 600 insertions, 0 deletions
diff --git a/docs/content/en/methods/pager/First.md b/docs/content/en/methods/pager/First.md
new file mode 100644
index 000000000..85e2e0dd3
--- /dev/null
+++ b/docs/content/en/methods/pager/First.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/HasNext.md b/docs/content/en/methods/pager/HasNext.md
new file mode 100644
index 000000000..e7550d788
--- /dev/null
+++ b/docs/content/en/methods/pager/HasNext.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/HasPrev.md b/docs/content/en/methods/pager/HasPrev.md
new file mode 100644
index 000000000..00d5c1dea
--- /dev/null
+++ b/docs/content/en/methods/pager/HasPrev.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/Last.md b/docs/content/en/methods/pager/Last.md
new file mode 100644
index 000000000..074a46943
--- /dev/null
+++ b/docs/content/en/methods/pager/Last.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/Next.md b/docs/content/en/methods/pager/Next.md
new file mode 100644
index 000000000..099ac198e
--- /dev/null
+++ b/docs/content/en/methods/pager/Next.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/NumberOfElements.md b/docs/content/en/methods/pager/NumberOfElements.md
new file mode 100644
index 000000000..3980cdfe2
--- /dev/null
+++ b/docs/content/en/methods/pager/NumberOfElements.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/PageGroups.md b/docs/content/en/methods/pager/PageGroups.md
new file mode 100644
index 000000000..9dee18c0d
--- /dev/null
+++ b/docs/content/en/methods/pager/PageGroups.md
@@ -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" . }}
+```
diff --git a/docs/content/en/methods/pager/PageNumber.md b/docs/content/en/methods/pager/PageNumber.md
new file mode 100644
index 000000000..0d99c5a15
--- /dev/null
+++ b/docs/content/en/methods/pager/PageNumber.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/PageSize.md b/docs/content/en/methods/pager/PageSize.md
new file mode 100644
index 000000000..a400f929a
--- /dev/null
+++ b/docs/content/en/methods/pager/PageSize.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/Pagers.md b/docs/content/en/methods/pager/Pagers.md
new file mode 100644
index 000000000..5f167c13e
--- /dev/null
+++ b/docs/content/en/methods/pager/Pagers.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/Pages.md b/docs/content/en/methods/pager/Pages.md
new file mode 100644
index 000000000..1c049d53b
--- /dev/null
+++ b/docs/content/en/methods/pager/Pages.md
@@ -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" . }}
+```
diff --git a/docs/content/en/methods/pager/Prev.md b/docs/content/en/methods/pager/Prev.md
new file mode 100644
index 000000000..c129c6a5a
--- /dev/null
+++ b/docs/content/en/methods/pager/Prev.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/TotalNumberOfElements.md b/docs/content/en/methods/pager/TotalNumberOfElements.md
new file mode 100644
index 000000000..3cd1c8dad
--- /dev/null
+++ b/docs/content/en/methods/pager/TotalNumberOfElements.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/TotalPages.md b/docs/content/en/methods/pager/TotalPages.md
new file mode 100644
index 000000000..e305beeff
--- /dev/null
+++ b/docs/content/en/methods/pager/TotalPages.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/URL.md b/docs/content/en/methods/pager/URL.md
new file mode 100644
index 000000000..3daddbbd5
--- /dev/null
+++ b/docs/content/en/methods/pager/URL.md
@@ -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 }}
+```
diff --git a/docs/content/en/methods/pager/_index.md b/docs/content/en/methods/pager/_index.md
new file mode 100644
index 000000000..58a1def7b
--- /dev/null
+++ b/docs/content/en/methods/pager/_index.md
@@ -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/