update post layout implementation

This commit is contained in:
geekifan
2025-04-22 13:45:20 +08:00
parent 8cd7c5bdc2
commit d24c640ab7
2 changed files with 11 additions and 6 deletions

View File

@ -16,7 +16,7 @@
<!-- layout specified --> <!-- layout specified -->
{{ if or (eq .Layout "post") (eq .Layout "page") $is_home }} {{ if or (eq .Type "post") (eq .Layout "page") $is_home }}
{{ with $data.lazyPolyfill.js }} {{ with $data.lazyPolyfill.js }}
{{ $urls = $urls | append . }} {{ $urls = $urls | append . }}
{{ end }} {{ end }}
@ -32,7 +32,7 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if or $is_home (eq .Layout "post") (eq .Layout "archives") (eq .Layout "category") (eq .Layout "tag") }} {{ if or $is_home (eq .Type "post") (eq .Layout "archives") (eq .Layout "category") (eq .Layout "tag") }}
{{ $locale := strings.TrimSuffix (path.Ext .Lang) .Lang }} {{ $locale := strings.TrimSuffix (path.Ext .Lang) .Lang }}
{{ with $data.dayjs.js.common }} {{ with $data.dayjs.js.common }}
@ -72,7 +72,7 @@
{{ $js = "home" }} {{ $js = "home" }}
{{ else if eq .Layout "categories" }} {{ else if eq .Layout "categories" }}
{{ $js = "categories" }} {{ $js = "categories" }}
{{ else if eq .Layout "post" }} {{ else if eq .Type "post" }}
{{ $js = "post" }} {{ $js = "post" }}
{{ else if eq .Layout "page" }} {{ else if eq .Layout "page" }}
{{ $js = "page" }} {{ $js = "page" }}
@ -93,7 +93,7 @@
{{ end }} {{ end }}
<!-- Pageviews --> <!-- Pageviews -->
{{ if eq .Layout "post" }} {{ if eq .Type "post" }}
{{ $provider := site.Params.pageviews.provider }} {{ $provider := site.Params.pageviews.provider }}
{{ if and $provider (ne $provider "") }} {{ if and $provider (ne $provider "") }}
{{ if eq $provider "goatcounter" }} {{ if eq $provider "goatcounter" }}

View File

@ -122,9 +122,9 @@
{{ with .Params.categories }} {{ with .Params.categories }}
<div class="post-meta mb-3"> <div class="post-meta mb-3">
<i class="far fa-folder-open fa-fw me-1"></i> <i class="far fa-folder-open fa-fw me-1"></i>
{{ $len := len . }}
{{ range $i, $category := . }} {{ range $i, $category := . }}
<a href="{{ "/categories/" | relLangURL }}{{ $category | urlize }}/">{{ $category }}</a> <a href="{{ "/categories/" | relLangURL }}{{ $category | urlize }}/">{{ $category }}</a>{{ if not (eq $i (sub $len 1)) }},{{ end }}
{{ if not (eq $i (sub (len $) 1)) }},{{ end }}
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}
@ -160,3 +160,8 @@
{{ define "panel" }} {{ define "panel" }}
{{ partial "toc.html" . }} {{ partial "toc.html" . }}
{{ end }} {{ end }}
{{ define "tail" }}
{{ partial "related-posts.html" . }}
{{ partial "post-nav.html" . }}
{{ end }}