Skip to content

Commit

Permalink
fix: deprecated warning for .Path
Browse files Browse the repository at this point in the history
fixed #369
  • Loading branch information
reuixiy committed Jan 26, 2022
1 parent 5e6c812 commit e425890
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
11 changes: 9 additions & 2 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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 }}

Expand Down
9 changes: 8 additions & 1 deletion layouts/partials/components/post-gitinfo.html
Original file line number Diff line number Diff line change
@@ -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">
Expand Down Expand Up @@ -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>
Expand Down
12 changes: 10 additions & 2 deletions layouts/partials/utils/title.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{{- $ := index . "$" -}}

{{- $path := "" -}}
{{- with .File -}}
{{- $path = .Path -}}
{{- else -}}
{{- $path = .Path -}}
{{- end -}}

{{- $htmlTitle := .title -}}
<!-- Home -->
{{- if eq $.Kind "home" -}}
Expand All @@ -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) -}}
Expand Down

0 comments on commit e425890

Please sign in to comment.