page_edit.html 1.0 KB

1234567891011121314151617
  1. {{/* Add link to let visitors edit the page on GitHub. */}}
  2. {{ if .Params.editable | and site.Params.features.repository.url }}
  3. {{/* Get language subfolder for multilingual sites. */}}
  4. {{/* Limitations: the subfolder param, `<LANG>.contentDir`, is unexposed in the Hugo `site` API so we attempt to workaround this issue. */}}
  5. {{ $content_dir := "content" }}
  6. {{ if site.Params.features.repository.content_dir }}
  7. {{ $content_dir = site.Params.features.repository.content_dir }}
  8. {{else}}
  9. {{/* Attempt to get content dir from the LanguagePrefix URI, but defaultContentLanguageInSubdir can break this assumption. */}}
  10. {{ $content_dir = cond site.IsMultiLingual (cond (ne .Site.LanguagePrefix "") (printf "%s%s" $content_dir .Site.LanguagePrefix) $content_dir) $content_dir }}
  11. {{end}}
  12. <p class="edit-page">
  13. <a href="{{site.Params.features.repository.url}}/edit/{{site.Params.features.repository.branch | default "main"}}/{{$content_dir}}/{{.File.Path}}">
  14. <i class="fas fa-pen pr-2"></i>{{ i18n "edit_page" | default "Edit this page" }}
  15. </a>
  16. </p>
  17. {{ end }}