-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination support for home page, sections and taxonomies #750
Conversation
a44fac6
to
5a36b21
Compare
@spf13 this should be pretty complete now. I might do something to improve integrationtesting and check on the performance characteristics (looks like just a slight overhead on my site), but it should work. I set the default for the paginator setting to 0. In the future, maybe the default should be 10 or something, but then we should have some pagination templates built in. See http://discuss.gohugo.io/t/pagination-implementation-feedback-appreciated/519/8 for more info. I will write some documentation if this one goes into the wild. |
9b4c2a1
to
b9062ac
Compare
Some kind tester found a issue that I will have to fix. EDIT IN: issue fixed, but this can stay in test modus for a day or two, me thinks. |
edd957e
to
e0a2f60
Compare
e0a2f60
to
8ee7815
Compare
8ee7815
to
b693b67
Compare
b693b67
to
2f81fba
Compare
I have an idea about how to improve this one. Will add to this PR. |
2f81fba
to
3399d19
Compare
Now it supports home page, sections and taxonomies -- and "all kinds of lists". |
9cac006
to
688d7fc
Compare
688d7fc
to
e6ac981
Compare
This is pretty brilliant! Thanks for contributing this. It's been the most requested feature for the past year. |
040051c
to
dcea325
Compare
Yes, I think it now has the right Hugo balance between simple. yet very powerful. I will add docs later, and we should probably provide an internal template ala the ul-section here: https://github.com/bjornerik/bepsays.com/blob/master/layouts/partials/pagination.html (Bootstrap-compatible). Feel free to merge, @spf13. Or I can do it myself if you do not object. |
Feel free to merge it. |
Two new configuration properties, `Paginate` (default `0`) and `PaginatePath` (default `page`) are added. Setting `paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of size of the `paginate` property. A `.Paginator` is provided to help building a pager menu. There are two ways to configure a `.Paginator`: 1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for "that page" (`.Data.Pages` will (like today) contain all the pages). 2. Select a sub-set of the pages with the available template functions and pass the slice to `.Paginate` : `{{ range (.Paginate (where .Data.Pages "Type" "post")).Pages }}` **NOTE:** For a given Node, it's one of the options above. It's perfectly legitimate to iterate over the same pager more than once, but it's static and cannot change. The `.Paginator` contains enough information to build a full-blown paginator interface. The pages are built on the form (note: BLANK means no value, i.e. home page): ``` [SECTION/TAXONOMY/BLANK]/index.html [SECTION/TAXONOMY/BLANK]/page/1/index.html => redirect to [SECTION/TAXONOMY/BLANK]/index.html [SECTION/TAXONOMY/BLANK]/page/2/index.html .... ``` Fixes #96
dcea325
to
75ef9da
Compare
Merged in 37445bc |
Wow thank you guys for great feature. :) |
10 is a better default than 0, since no paginator pages will be created unles referenced by a `.Paginator`. See #750
10 is a better default than 0, since no paginator pages will be created unles referenced by a `.Paginator`. See gohugoio#750
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Two new configuration properties,
Paginate
(default0
) andPaginatePath
(defaultpage
) are added.Setting
paginate
to a positive value will split the list pages for the home page, sections and taxonomies into chunks of size of thepaginate
property.A
.Paginator
is provided to help building a pager menu.There are two ways to configure a
.Paginator
:.Paginator.Pages
from a template. It will contain the pages for "that page" (.Data.Pages
will (like today) contain all the pages)..Paginate
:{{ range (.Paginate (where .Data.Pages "Type" "post")).Pages }}
NOTE: For a given Node, it's one of the options above. It's perfectly legitimate to iterate over the same pager more than once, but it's static and cannot change.
The
.Paginator
contains enough information to build a full-blown paginator interface.The pages are built on the form (note: BLANK means no value, i.e. home page and
page
can be replaced by setting thePaginatePath
):Fixes #96