-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
600 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" . }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} | ||
``` |
Oops, something went wrong.