feat: address Hugo v0.92 notice RE changing behaviour of .Path (#2642)

This commit is contained in:
Mickaël Canouil 2022-03-03 21:24:39 +01:00 committed by GitHub
commit 97a4b87534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View file

@ -14,7 +14,7 @@
{{/* Show the About widget if an account exists for this user. */}}
{{ if .File }}
{{ $widget := "widgets/about.html" }}
{{ $username := (path.Base (path.Split .Path).Dir) }}{{/* Alternatively, use `index .Params.authors 0` */}}
{{ $username := (path.Base .File.Dir) }}{{/* Alternatively, use `index .Params.authors 0` */}}
{{ $params := dict "root" $ "page" . "author" $username }}
{{ partial $widget $params }}
{{end}}

View file

@ -27,7 +27,7 @@
{{/* Correct the title and URL for author profile pages. */}}
{{- if eq .Section "authors" -}}
{{- $username := path.Base (path.Split .Path).Dir -}}
{{- $username := path.Base .File.Dir -}}
{{- with site.GetPage (printf "/authors/%s" $username) -}}
{{- $permalink = .Permalink -}}
{{- $rel_permalink = .RelPermalink -}}

View file

@ -53,7 +53,7 @@
{{ $superuser_role := "" }}
{{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }}
{{ $superuser_name = .Title }}
{{ $superuser_username = path.Base (path.Split .Path).Dir }}
{{ $superuser_username = path.Base .File.Dir }}
{{ $superuser_role = .Params.role }}
{{ end }}
{{ $scr.Set "superuser_username" $superuser_username }}{{/* Set superuser globally for page_author.html. */}}

View file

@ -89,7 +89,7 @@
{{ end }}
{{/* Fix Hugo's ContentBaseName returning wrong file base name when page section is within a bundle. */}}
{{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
{{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base .File.Dir) }}
{{ $widget := or $st.Params.widget "blank" }}
{{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}

View file

@ -35,7 +35,7 @@
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
{{/* Get link to user's profile page. */}}
{{ $link := "" }}
{{ with site.GetPage (printf "/authors/%s" (path.Base (path.Split .Path).Dir)) }}
{{ with site.GetPage (printf "/authors/%s" (path.Base .File.Dir)) }}
{{ $link = .RelPermalink }}
{{ end }}
<div class="col-12 col-sm-auto people-person">

View file

@ -7,7 +7,7 @@
{{/* Validate Pub Type if defined */}}
{{ if gt $pub_type (sub (len $pub_types) 1) }}
{{ warnf "Unknown publication type in %s" .Path }}
{{ warnf "Unknown publication type in %s" .File.Path }}
{{ $pub_type = 0 }}
{{ end }}