Skip to content
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

Fix list pagination #240

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "main" }}
{{ $paginator := .Paginate (.Pages | lang.Merge (where .Sites.First.RegularPages "Section" .Section)) }}
{{ $section_to_display := .Sections | default $paginator.Pages }}
{{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display ) }}
{{ partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display "pagination_data" .) }}
{{ end }}
4 changes: 4 additions & 0 deletions layouts/partials/pagelayout.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ <h1 class="primary-color-dark f2">
</section>
</div>

<div class="nested-list-reset nested-links">
{{/* pagination.html: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/template_embedded.go#L117 */}}
{{ template "_internal/pagination.html" .pagination_data }}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I initially tried using .context but it did not work with the following error

failed to render pages: render of "page" failed: execute of template failed at <partial "pagelayout.html" (dict "context" . "section_to_display" $section_to_display)>: error calling partial: execute of template failed at <$page.Paginator.TotalPages>: error calling TotalPages: runtime error: invalid memory address or nil pointer dereference

  • Am not too familiar with the inner workings thus added a separate key to the dict and it worked

So if there is a cleaner way do let me know and will be happy to change and confirm how it goes

</div>
</div>

</div>
Expand Down