mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
tpl/tplimpl: Extract internal templates
Having them in separate files should make maintainance easier. When adding new or making changes to the templates: ```bash mage generate ``` This will get the Go code in sync. Fixes #4457
This commit is contained in:
42
tpl/tplimpl/embedded/templates/pagination.html
Executable file
42
tpl/tplimpl/embedded/templates/pagination.html
Executable file
@@ -0,0 +1,42 @@
|
||||
{{ $pag := $.Paginator }}
|
||||
{{ if gt $pag.TotalPages 1 }}
|
||||
<ul class="pagination">
|
||||
{{ with $pag.First }}
|
||||
<li>
|
||||
<a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">««</span></a>
|
||||
</li>
|
||||
{{ end }}
|
||||
<li
|
||||
{{ if not $pag.HasPrev }}class="disabled"{{ end }}>
|
||||
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
||||
</li>
|
||||
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
||||
{{ range $pag.Pagers }}
|
||||
{{ $right := sub .TotalPages .PageNumber }}
|
||||
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
||||
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
||||
{{ if $showNumber }}
|
||||
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
||||
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
|
||||
{{ $.Scratch.Set "__paginator.ellipsed" true }}
|
||||
{{ end }}
|
||||
{{ if $showNumber }}
|
||||
<li
|
||||
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li>
|
||||
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
|
||||
<li class="disabled"><span aria-hidden="true">…</span></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<li
|
||||
{{ if not $pag.HasNext }}class="disabled"{{ end }}>
|
||||
<a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a>
|
||||
</li>
|
||||
{{ with $pag.Last }}
|
||||
<li>
|
||||
<a href="{{ .URL }}" aria-label="Last"><span aria-hidden="true">»»</span></a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
Reference in New Issue
Block a user