From d24c640ab7d80addf33adcd4f5a503bff2431d5c Mon Sep 17 00:00:00 2001 From: geekifan Date: Tue, 22 Apr 2025 13:45:20 +0800 Subject: [PATCH] update post layout implementation --- layouts/partials/js-selector.html | 8 ++++---- layouts/{_default/post.html => post/single.html} | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) rename layouts/{_default/post.html => post/single.html} (96%) diff --git a/layouts/partials/js-selector.html b/layouts/partials/js-selector.html index 847de4f..a9e468a 100644 --- a/layouts/partials/js-selector.html +++ b/layouts/partials/js-selector.html @@ -16,7 +16,7 @@ -{{ if or (eq .Layout "post") (eq .Layout "page") $is_home }} +{{ if or (eq .Type "post") (eq .Layout "page") $is_home }} {{ with $data.lazyPolyfill.js }} {{ $urls = $urls | append . }} {{ end }} @@ -32,7 +32,7 @@ {{ 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 }} {{ with $data.dayjs.js.common }} @@ -72,7 +72,7 @@ {{ $js = "home" }} {{ else if eq .Layout "categories" }} {{ $js = "categories" }} -{{ else if eq .Layout "post" }} +{{ else if eq .Type "post" }} {{ $js = "post" }} {{ else if eq .Layout "page" }} {{ $js = "page" }} @@ -93,7 +93,7 @@ {{ end }} -{{ if eq .Layout "post" }} +{{ if eq .Type "post" }} {{ $provider := site.Params.pageviews.provider }} {{ if and $provider (ne $provider "") }} {{ if eq $provider "goatcounter" }} diff --git a/layouts/_default/post.html b/layouts/post/single.html similarity index 96% rename from layouts/_default/post.html rename to layouts/post/single.html index ea8d4d6..cb59b61 100644 --- a/layouts/_default/post.html +++ b/layouts/post/single.html @@ -122,9 +122,9 @@ {{ with .Params.categories }}
+ {{ $len := len . }} {{ range $i, $category := . }} - {{ $category }} - {{ if not (eq $i (sub (len $) 1)) }},{{ end }} + {{ $category }}{{ if not (eq $i (sub $len 1)) }},{{ end }} {{ end }}
{{ end }} @@ -159,4 +159,9 @@ {{ define "panel" }} {{ partial "toc.html" . }} +{{ end }} + +{{ define "tail" }} + {{ partial "related-posts.html" . }} + {{ partial "post-nav.html" . }} {{ end }} \ No newline at end of file