mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Pagination - do not render href if no next item
When using a html link checker with Hugo, this template consistently causes errors, as it renders `href=""` attributes when next/previous is disabled. This change makes it so that the `href` attribute is not rendered at all if `HasNext` is false - which is better semantically, and makes link checking far easier.
This commit is contained in:
parent
59c4bc52ed
commit
88c8a15be1
1 changed files with 3 additions and 3 deletions
|
@ -7,7 +7,7 @@
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
|
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
|
||||||
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
<a {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }} class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
||||||
</li>
|
</li>
|
||||||
{{ $ellipsed := false }}
|
{{ $ellipsed := false }}
|
||||||
{{ $shouldEllipse := false }}
|
{{ $shouldEllipse := false }}
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
|
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
|
||||||
<a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
|
<a {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }} class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
|
||||||
</li>
|
</li>
|
||||||
{{ with $pag.Last }}
|
{{ with $pag.Last }}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
|
@ -37,4 +37,4 @@
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue