mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-06 14:14:04 +00:00
fix: workaround Hugo GetPage/urlize bug with non-ASCII usernames
Attempt to use anchorize rather than urlize for fetching user profiles for users with non-ASCII usernames. Apparently `anchorize` does not perform URL encoding unlike `urlize`, so may be better suited for use with `GetPage`. See https://github.com/gohugoio/hugo/issues/5687
This commit is contained in:
1 parent
5c6c8770b1
commit
03af4df12a
6 files changed
+6
-6
No files matched your search
+1
-1
@@ -40,7 +40,7 @@
|
||||
{{- if gt $authorLen 0 -}}
|
||||
{{- $authors = slice -}}
|
||||
{{- range $k, $v := .Params.authors -}}
|
||||
{{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}}
|
||||
{{- $person_page_path := (printf "/authors/%s" (anchorize $v)) -}}
|
||||
{{- $person_page := site.GetPage $person_page_path -}}
|
||||
{{- if and $person_page $person_page.File -}}
|
||||
{{- $person := $person_page.Params -}}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{ $author_username = $page.Scratch.Get "superuser_username" }}
|
||||
{{ else if $page.Params.authors }}
|
||||
{{ $author = index $page.Params.authors 0 }}
|
||||
{{ $author_username = urlize $author }}
|
||||
{{ $author_username = anchorize $author }}
|
||||
{{ end }}
|
||||
|
||||
{{ $taxonomy := "authors" }}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{ if .Params.authors }}
|
||||
{{ $first_author = index .Params.authors 0 }}
|
||||
{{ end }}
|
||||
{{ $author_urlized = urlize $first_author }}
|
||||
{{ $author_urlized = anchorize $first_author }}
|
||||
{{ end }}
|
||||
|
||||
{{ $site_type := site.Params.site_type | default "Person" }}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{{ with .Param $taxonomy }}
|
||||
{{ $link_authors := site.Params.link_authors | default true }}
|
||||
{{ range $index, $value := . }}
|
||||
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | urlize)) -}}
|
||||
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | anchorize)) -}}
|
||||
{{- $name := $profile_page.Params.name | default ($value|markdownify) -}}
|
||||
{{- if gt $index 0 }}, {{ end -}}
|
||||
<span>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{ $author = $page.Params.author }}
|
||||
{{end}}
|
||||
|
||||
{{ $person_page_path := (printf "/authors/%s" (urlize $author)) }}
|
||||
{{ $person_page_path := (printf "/authors/%s" (anchorize $author)) }}
|
||||
{{ $person_page := site.GetPage $person_page_path }}
|
||||
{{ if not $person_page }}
|
||||
{{ errorf "Could not find an author page at `%s`. Please check the value of `author` in your About widget and create an associated author page if one does not already exist. See https://sourcethemes.com/academic/docs/page-builder/#about " $person_page_path }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- $username := .Get 0 -}}
|
||||
{{- $username_url := $username | urlize -}}
|
||||
{{- $username_url := $username | anchorize -}}
|
||||
{{- $taxonomy := "authors" -}}
|
||||
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $username_url) -}}
|
||||
{{- $name := $profile_page.Params.name | default ($username|markdownify) -}}
|
||||
|
||||
Reference in new issue
Block a user