zregvart commented on a change in pull request #295: Custom Pagination within Blog Section URL: https://github.com/apache/camel-website/pull/295#discussion_r401452269
########## File path: layouts/blog/list.html ########## @@ -15,9 +15,46 @@ <h3>Categories</h3> {{ range $pages }} {{ .Render "summary" }} {{ end }} - {{ template "_internal/pagination.html" . }} + + {{ $page := .Paginator }} + {{ if gt $page.TotalPages 1 }} + {{ $.Scratch.Set "dot_rendered" false }} + <nav aria-label="page navigation"> + <ul class="pagination"> + <!-- Don't show on 1st and 2nd page --> + {{ if and (ne $page.PageNumber 1) }} + <li class="page-item"><a href="{{ $page.First.URL }}" rel="first" class="page-link">««</a></li> + {{ end }} + + {{ if $page.HasPrev }} + <li class="page-item"><a href="{{ $page.Prev.URL }}" rel="prev" class="page-link">«</a></li> + {{ end }} + + {{ range $page.Pagers }} + {{ if eq . $page }} <!-- Current Page --> + <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li> + {{ else if and (ge .PageNumber (sub $page.PageNumber 2)) (le .PageNumber (add $page.PageNumber 2)) }} + {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages --> + <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li> + {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages --> + {{ $.Scratch.Set "dot_rendered" true }} + <li class="page-item disabled"><a class="page-link">...</a></li> + {{ end }} + {{ end }} + + {{ if $page.HasNext }} + <li class="page-item"><a href="{{ $page.Next.URL }}" rel="next" class="page-link">»</a></li> + {{ end }} + + <!-- Don't show on last and 2nd last page --> + {{ if and (ne $page.PageNumber $page.TotalPages) }} + <li class="page-item"><a href="{{ $page.Last.URL }}" rel="last" class="page-link">»»</a></li> + {{ end }} + </ul> + </nav> + {{ end }} </div> </main> </div> -{{ partial "footer.html" . }} +{{ partial "footer.html" . }} Review comment: No newline at EOF ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services