From c41eaa135b6efd9029e8a52e633eaddf4a4698f2 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 18 Apr 2025 14:40:33 +0800 Subject: refactor: separate post single template and page template Former-commit-id: 4f0ebaeed13c1c44c7d7c5778b187b69f5849552 --- layouts/_default/single.html | 61 +++--------------------------------- layouts/posts/single.html | 73 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 57 deletions(-) create mode 100644 layouts/posts/single.html (limited to 'layouts') diff --git a/layouts/_default/single.html b/layouts/_default/single.html index f81f9208..bfe80ad5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,46 +1,10 @@ {{ define "main" }} - {{ if eq .Type "posts" }} - {{ partial "components/post-page-header.html" . }} - {{ else }} - {{ partial "header.html" . }} - {{ end }} + {{ partial "header.html" . }}
- -
- {{ if in .Site.Params.mainSections .Type }} - {{ partial "components/banner.html" . }} - -

- {{ .Title }} - {{ with .Params.subtitle }} - {{ . }} - {{ end }} -

- - - {{ end }} -
- - +
{{ if .Params.toc }} @@ -48,23 +12,8 @@ {{ end }} {{ .Site.Params.postHeaderContent | safeHTML }} {{ .Content }} - {{ if and (eq .Site.Language.Lang "zh") (eq .Section "posts") }} -

如果你觉得文章对你有帮助,可以考虑赞助作者

- {{ end }}
- {{ if in .Site.Params.mainSections .Type }} - {{ partial "components/comment.html" . }} - {{ with site.RegularPages.Related . | first 5 }} -

{{ T "relatedContent" }}

- - {{ end }} - {{ end }} -
- {{ if ne .Type "posts" }} - {{ partial "footer.html" . }} - {{ end }} + {{ partial "footer.html" . }} {{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html new file mode 100644 index 00000000..525db84d --- /dev/null +++ b/layouts/posts/single.html @@ -0,0 +1,73 @@ +{{ define "main" }} + {{ partial "components/post-page-header.html" . }} +
+ +
+ {{ partial "components/banner.html" . }} + +

+ {{ .Title }} + {{ with .Params.subtitle }} + {{ . }} + {{ end }} +

+ + +
+ + +
+ {{ if .Params.toc }} +
+ {{ end }} + {{ .Site.Params.postHeaderContent | safeHTML }} + {{ .Content }} + {{ if eq .Site.Language.Lang "zh" }} +

如果你觉得文章对你有帮助,可以考虑赞助作者

+ {{ end }} +
+ + {{ partial "components/comment.html" . }} + + {{ with site.RegularPages.Related . | first 5 }} +

{{ T "relatedContent" }}

+ + {{ end }} + + + + +
+{{ end }} -- cgit v1.2.3