Files
George Cushen ef8ed449c7 feat(hugo): replace deprecated APIs for Hugo v0.156+ compatibility
Migrate site.Data → hugo.Data (42 occurrences), site.IsMultiLingual →
hugo.IsMultilingual, and site.AllPages → hugo.Sites nested range.
Simplify Netlify redirects template to use pre-processed aliases
instead of relLangURL per gohugoio/hugo#14408.
2026-03-27 03:25:42 +00:00

19 lines
1.1 KiB
HTML

{{/* Add link to let visitors edit the page on GitHub. */}}
{{/* Perform short-circuit check that page is backed by a file. */}}
{{ if and .File .Params.editable | and site.Params.hugoblox.repository.url }}
{{/* Get language subfolder for multilingual sites. */}}
{{/* Limitations: the subfolder param, `<LANG>.contentDir`, is unexposed in the Hugo `site` API so we attempt to workaround this issue. */}}
{{ $content_dir := "content" }}
{{ if site.Params.hugoblox.repository.content_dir }}
{{ $content_dir = site.Params.hugoblox.repository.content_dir }}
{{else}}
{{/* Attempt to get content dir from the LanguagePrefix URI, but defaultContentLanguageInSubdir can break this assumption. */}}
{{ $content_dir = cond hugo.IsMultilingual (cond (ne .Site.LanguagePrefix "") (printf "%s%s" $content_dir .Site.LanguagePrefix) $content_dir) $content_dir }}
{{end}}
<p class="edit-page">
<a href="{{site.Params.hugoblox.repository.url}}/edit/{{site.Params.hugoblox.repository.branch | default "main"}}/{{$content_dir}}/{{.File.Path}}">
📝 {{ i18n "edit_page" | default "Edit this page" }}
</a>
</p>
{{ end }}