diff options
author | reuixiy <reuixiy@gmail.com> | 2022-01-26 17:51:32 +0300 |
---|---|---|
committer | reuixiy <reuixiy@gmail.com> | 2022-01-26 17:58:57 +0300 |
commit | e4258903032a6a6b3b27ca3603652c11b167ace3 (patch) | |
tree | 1e28c58e1318d0cc52813d21fbe6ccc9b75b28c9 | |
parent | 5e6c8123a1d61fe5c097781ab1f1f45846467114 (diff) |
fix: deprecated warning for .Path
fixed #369
-rw-r--r-- | layouts/_default/list.html | 11 | ||||
-rw-r--r-- | layouts/partials/components/post-gitinfo.html | 9 | ||||
-rw-r--r-- | layouts/partials/utils/title.html | 12 |
3 files changed, 27 insertions, 5 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index f294c2d..e3a49f9 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,4 +1,11 @@ {{ define "main" }} + {{- $path := "" -}} + {{- with .File -}} + {{- $path = .Path -}} + {{- else -}} + {{- $path = .Path -}} + {{- end -}} + {{ if and (eq .Kind "section") .Content }} {{ partial "pages/post.html" . }} {{ else }} @@ -7,10 +14,10 @@ <div class="content list-group"> {{ if .Site.Params.displayListTitle }} {{ if (eq .Kind "section") }} - <h1 class="list-title">{{ .Title | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" .Path) "/")) " ") }}</h1> + <h1 class="list-title">{{ .Title | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") }}</h1> {{ end }} {{ if (eq .Kind "term") }} - <h1 class="list-title">{{ .Title | default .Data.Term | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" .Path) "/")) " ") }}</h1> + <h1 class="list-title">{{ .Title | default .Data.Term | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") }}</h1> {{ end }} {{ end }} diff --git a/layouts/partials/components/post-gitinfo.html b/layouts/partials/components/post-gitinfo.html index 17fcd38..5a5a8a8 100644 --- a/layouts/partials/components/post-gitinfo.html +++ b/layouts/partials/components/post-gitinfo.html @@ -1,3 +1,10 @@ +{{- $path := "" -}} +{{- with .File -}} + {{- $path = .Path -}} +{{- else -}} + {{- $path = .Path -}} +{{- end -}} + {{ if .GitInfo }} {{ if and .Site.Params.enablePostGitInfo (.Params.gitinfo | default .Site.Params.displayPostGitInfo) }} <div class="post-gitinfo"> @@ -42,7 +49,7 @@ {{ with .Site.Params.repoEditURL }} {{ $contentDir := (cond $.Site.IsMultiLingual (printf `/%s/` $.Site.Params.contentDir) "/content/") }} <div class="gitinfo-item edit"> - <a href="{{ . }}{{ $contentDir }}{{ replace $.Path "\\" "/" }}" target="_blank" rel="noopener"> + <a href="{{ . }}{{ $contentDir }}{{ replace $path "\\" "/" }}" target="_blank" rel="noopener"> {{- partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.editIcon "class" "edit-icon") -}} {{- $.Site.Params.editText -}} </a> diff --git a/layouts/partials/utils/title.html b/layouts/partials/utils/title.html index be08c99..9bc9ebd 100644 --- a/layouts/partials/utils/title.html +++ b/layouts/partials/utils/title.html @@ -1,4 +1,12 @@ {{- $ := index . "$" -}} + +{{- $path := "" -}} +{{- with .File -}} + {{- $path = .Path -}} +{{- else -}} + {{- $path = .Path -}} +{{- end -}} + {{- $htmlTitle := .title -}} <!-- Home --> {{- if eq $.Kind "home" -}} @@ -8,13 +16,13 @@ {{- $htmlTitle = $htmlTitle | default ($.Type | title) -}} <!-- Taxonomy Term --> {{- else if eq $.Kind "term" -}} - {{- $taxonomyTermTitle := $htmlTitle | default $.Data.Term | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $.Path) "/")) " ") -}} + {{- $taxonomyTermTitle := $htmlTitle | default $.Data.Term | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") -}} {{- with $.Site.GetPage (printf "/%s" $.Data.Plural) -}} {{- $htmlTitle = printf "%s: %s" (.Title | default (.Type | title)) $taxonomyTermTitle -}} {{- end -}} <!-- Section --> {{- else if eq $.Kind "section" -}} - {{- $htmlTitle = $htmlTitle | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $.Path) "/")) " ") -}} + {{- $htmlTitle = $htmlTitle | default (delimit (last 1 (split (strings.TrimSuffix "/_index.md" $path) "/")) " ") -}} {{- end -}} {{- $htmlTitle = partial "utils/markdownify.html" (dict "$" $ "raw" $htmlTitle "isContent" false) -}} |