mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-14 04:15:40 +00:00
fix: "Edit Page" links for multilingual sites
Fix #1232 Fix sourcethemes/academic-www#14
This commit is contained in:
1 parent
15e00e60de
commit
c3c4d9560a
2 files changed
+11
-3
No files matched your search
@@ -75,7 +75,7 @@ privacy_pack = false
|
||||
|
||||
# Enable visitors to edit pages?
|
||||
# `repo` defines the repository URL. `editable` defines which page types can be edited.
|
||||
edit_page = {repo_url = "https://github.com/gcushen/hugo-academic", repo_branch = "master", editable = {docs = true, page = false, post = false}}
|
||||
edit_page = {repo_url = "https://github.com/gcushen/hugo-academic", content_dir = "", repo_branch = "master", editable = {docs = true, page = false, post = false}}
|
||||
|
||||
############################
|
||||
## Contact details
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
{{ if site.Params.edit_page }}{{/* Make `edit_page` optional in `params.toml` - prevent errors if it's removed. */}}
|
||||
{{ if site.Params.edit_page.repo_url | and (index site.Params.edit_page.editable .Type) | and (ne .Params.editable false) | or .Params.editable }}
|
||||
{{ $content_subfolder := cond site.IsMultiLingual (cond (ne .Site.LanguagePrefix "") (printf "%s/" .Site.LanguagePrefix) "") "" }}
|
||||
{{/* 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.edit_page.content_dir }}
|
||||
{{ $content_dir = site.Params.edit_page.content_dir }}
|
||||
{{else}}
|
||||
{{/* Attempt to get content dir from the LanguagePrefix URI, but defaultContentLanguageInSubdir can break this assumption. */}}
|
||||
{{ $content_dir = cond site.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.edit_page.repo_url}}/edit/{{site.Params.edit_page.repo_branch | default "master"}}/content/{{$content_subfolder}}{{.File.Path}}">
|
||||
<a href="{{site.Params.edit_page.repo_url}}/edit/{{site.Params.edit_page.repo_branch | default "master"}}/{{$content_dir}}/{{.File.Path}}">
|
||||
<i class="fas fa-pen pr-2"></i>{{ i18n "edit_page" | default "Edit this page" }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user