fix: update previous/next post links in footer

Addressing the deprecated .Page.PrevPage and .Page.NextPage variables in Hugo 0.137.0
This commit is contained in:
Mojtaba Yousefi 2024-10-18 09:58:31 -04:00
parent 23b85481b6
commit 07a5a28d0f

View file

@ -2,72 +2,43 @@
<hr /> <hr />
<div class="previous-post" style="display:inline-block;"> <div class="previous-post" style="display:inline-block;">
{{ if .PrevPage }} {{ if .Prev }}
<a class="link-reverse" href="{{ .PrevPage.Permalink }}?ref=footer">« {{ .PrevPage.Title | truncate 50 "..."}}</a> <a class="link-reverse" href="{{ .Prev.Permalink }}?ref=footer">« {{ .Prev.Title | truncate 50 "..."}}</a> {{ end }}
{{ end }}
</div> </div>
<div class="next-post" , style="display:inline-block;float:right;"> <div class="next-post" , style="display:inline-block;float:right;">
{{ if .NextPage }} {{ if .Next }}
<a class="link-reverse" href="{{ .NextPage.Permalink }}?ref=footer">{{ .NextPage.Title | truncate 50 "..." }} »</a> <a class="link-reverse" href="{{ .Next.Permalink }}?ref=footer">{{ .Next.Title | truncate 50 "..." }} »</a> {{ end }}
{{ end }}
</div> </div>
<ul class="page-footer-menu"> <ul class="page-footer-menu">
{{/* SOCIALS */}} {{/* SOCIALS */}} {{ if isset .Site.Params "twitter" }}
{{ if isset .Site.Params "twitter" }}
<li><a href="https://twitter.com/{{.Site.Params.twitter}}">Twitter</a></li> <li><a href="https://twitter.com/{{.Site.Params.twitter}}">Twitter</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "linkedin" }}
{{ if isset .Site.Params "linkedin" }}
<li><a href="https://linkedin.com/in/{{.Site.Params.linkedin}}">LinkedIn</a></li> <li><a href="https://linkedin.com/in/{{.Site.Params.linkedin}}">LinkedIn</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "github" }}
{{ if isset .Site.Params "github" }}
<li><a href="https://github.com/{{.Site.Params.github}}">GitHub</a></li> <li><a href="https://github.com/{{.Site.Params.github}}">GitHub</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "gitlab" }}
{{ if isset .Site.Params "gitlab" }}
<li><a href="https://gitlab.com/{{.Site.Params.gitlab}}">GitLab</a></li> <li><a href="https://gitlab.com/{{.Site.Params.gitlab}}">GitLab</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "patreon" }}
{{ if isset .Site.Params "patreon" }}
<li><a href="https://www.patreon.com/{{.Site.Params.patreon}}">Patreon</i></a></li> <li><a href="https://www.patreon.com/{{.Site.Params.patreon}}">Patreon</i></a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "youtube" }}
{{ if isset .Site.Params "youtube" }}
<li><a href="https://www.youtube.com/{{.Site.Params.youtube}}">YouTube</a></li> <li><a href="https://www.youtube.com/{{.Site.Params.youtube}}">YouTube</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "medium" }}
{{ if isset .Site.Params "medium" }}
<li><a href="https://medium.com/{{.Site.Params.medium}}">Medium</a></li> <li><a href="https://medium.com/{{.Site.Params.medium}}">Medium</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "reddit" }}
{{ if isset .Site.Params "reddit" }}
<li><a href="https://www.reddit.com/user/{{.Site.Params.reddit}}">Reddit</a></li> <li><a href="https://www.reddit.com/user/{{.Site.Params.reddit}}">Reddit</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "stackoverflow" }}
{{ if isset .Site.Params "stackoverflow" }}
<li><a href="https://stackoverflow.com/users/{{.Site.Params.stackoverflow}}?tab=profile">StackOverflow</a></li> <li><a href="https://stackoverflow.com/users/{{.Site.Params.stackoverflow}}?tab=profile">StackOverflow</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "instagram" }}
{{ if isset .Site.Params "instagram" }}
<li><a href="https://www.instagram.com/{{.Site.Params.instagram}}">Instagram</a></li> <li><a href="https://www.instagram.com/{{.Site.Params.instagram}}">Instagram</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "mastodon" }}
{{ if isset .Site.Params "mastodon" }}
<li><a href="https://{{.Site.Params.mastodon}}">Mastodon</a></li> <li><a href="https://{{.Site.Params.mastodon}}">Mastodon</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "orcid" }}
{{ if isset .Site.Params "orcid" }}
<li><a href="https://orcid.org/{{.Site.Params.orcid}}">ORCID</a></li> <li><a href="https://orcid.org/{{.Site.Params.orcid}}">ORCID</a></li>
{{ end }} {{ end }} {{ if isset .Site.Params "google_scholar" }}
{{ if isset .Site.Params "google_scholar" }}
<li><a href="https://scholar.google.com/citations?user={{.Site.Params.google_scholar}}">Google Scholar</a></li> <li><a href="https://scholar.google.com/citations?user={{.Site.Params.google_scholar}}">Google Scholar</a></li>
{{ end }} {{ end }} {{/* END SOCIALS */}} {{ range .Site.Menus.footer }}
{{/* END SOCIALS */}}
{{ range .Site.Menus.footer }}
<li><a href="{{.URL}}">{{.Pre }} {{ .Name }}</a></li> <li><a href="{{.URL}}">{{.Pre }} {{ .Name }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
@ -77,18 +48,10 @@
Powered by <a href="https://gohugo.io">Hugo</a> and the Powered by <a href="https://gohugo.io">Hugo</a> and the
<a href="https://github.com/loikein/hugo-tufte">Tufte theme</a>. <a href="https://github.com/loikein/hugo-tufte">Tufte theme</a>.
</p> </p>
{{ end }} {{ end }} {{ if or ( isset .Site.Params "copyright" ) ( isset .Site.Params "copyrightHolder" ) }}
{{ if or ( isset .Site.Params "copyright" ) ( isset .Site.Params "copyrightHolder" ) }}
<div class="copyright"> <div class="copyright">
<p> <p>
{{ with .Site.Params.copyright }} {{ with .Site.Params.copyright }} {{ . | safeHTML }} {{ else }} &copy; {{now.Format "2006"}} {{ with .Site.Params.copyrightHolder }}{{ . }}{{end}}. All rights reserved. {{end}}
{{ . | safeHTML }}
{{ else }}
&copy; {{now.Format "2006"}}
{{ with .Site.Params.copyrightHolder }}{{ . }}{{end}}.
All rights reserved.
{{end}}
</p> </p>
</div> </div>
{{ end }} {{ end }}