From 5cb1c7eb72fad939bcc76be11e4b6149f37618e1 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 27 Nov 2025 23:35:37 +0800 Subject: feat: adapt to new content system - remove more posts link in homepage - more latest content (posts, essays, library, fictions...) in homepage - use the same template for posts and essays - new post section list style - show section-specific categories in section page Former-commit-id: 9a478cf5ee77a32b83dbe8f03d7ed8e83247937f --- content/essays/_index.md | 2 +- layouts/_partials/home/latest-posts.html | 6 +--- layouts/_partials/section-categories.html | 20 +++++++++++++ layouts/_partials/template/post-page.html | 47 ++++++++++++++++++++++++++++++ layouts/essays/page.html | 3 ++ layouts/essays/section.html | 4 ++- layouts/posts/page.html | 48 +------------------------------ layouts/section.html | 40 +++++++++++++++++++------- 8 files changed, 105 insertions(+), 65 deletions(-) create mode 100644 layouts/_partials/section-categories.html create mode 100644 layouts/_partials/template/post-page.html create mode 100644 layouts/essays/page.html diff --git a/content/essays/_index.md b/content/essays/_index.md index ef4ec1af..3baeb14e 100644 --- a/content/essays/_index.md +++ b/content/essays/_index.md @@ -2,4 +2,4 @@ title: 议论集 --- -在无边信息海洋里,我的武装。 +博客上相对严谨的部分,有关好奇心、知识、人类,以及如何思考。 diff --git a/layouts/_partials/home/latest-posts.html b/layouts/_partials/home/latest-posts.html index 2a0beccd..ac015111 100644 --- a/layouts/_partials/home/latest-posts.html +++ b/layouts/_partials/home/latest-posts.html @@ -1,7 +1,7 @@
{{ $firstPost := true }} - {{ range first 5 (where site.RegularPages "Type" "in" site.Params.mainSections) }} + {{ range first 12 (where site.RegularPages "Type" "in" site.Params.mainSections) }} {{ partial "items/post" (dict "ctx" . "showSummary" $firstPost @@ -9,7 +9,3 @@ {{ $firstPost = false }} {{ end }}
- - - {{ T "moreLinks.posts" }} → - diff --git a/layouts/_partials/section-categories.html b/layouts/_partials/section-categories.html new file mode 100644 index 00000000..5e92bcc3 --- /dev/null +++ b/layouts/_partials/section-categories.html @@ -0,0 +1,20 @@ +{{ $categories := slice }} +{{ range . }} + {{ with .Params.categories }} + {{ if not (in $categories .) }} + {{ $categories = $categories | append . }} + {{ end }} + {{ end }} +{{ end }} + +
+ {{ range $categories }} + + {{ . }} + + {{ end }} +
diff --git a/layouts/_partials/template/post-page.html b/layouts/_partials/template/post-page.html new file mode 100644 index 00000000..39d8c875 --- /dev/null +++ b/layouts/_partials/template/post-page.html @@ -0,0 +1,47 @@ +
+ +
+ {{ if .Params.banner }} + {{ partial "components/logo" (dict + "class" "block round-sticker w-14 h-14 lg:w-28 lg:h-28 right-2 lg:-right-20 top-2 lg:top-4 absolute rotate-[3.0deg]" + "imageClass" "block w-full" + ) }} + {{ else }} + {{ partial "components/logo" (dict + "class" "block w-[10rem]" + "imageClass" "block w-full" + ) }} + {{ end }} + + {{ partial "posts/banner" . }} + +

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

+ +
+ {{ partial "components/date" . }} + {{ if or .Params.categories .Params.tags }}·{{ end }} + {{ partial "components/category-pill" . }} + {{ partial "components/tags" . }} +
+
+ + +
+ {{ partial "posts/toc" . }} +
{{ .Content }}
+ {{ partial "posts/endnotes" . }} +
+ + {{ partial "posts/action-menu.html" . }} + {{ partial "posts/now-read-this.html" . }} + {{ partial "components/back-to-top.html" . }} +
diff --git a/layouts/essays/page.html b/layouts/essays/page.html new file mode 100644 index 00000000..e093e810 --- /dev/null +++ b/layouts/essays/page.html @@ -0,0 +1,3 @@ +{{ define "main" }} + {{ partial "template/post-page" . }} +{{ end }} diff --git a/layouts/essays/section.html b/layouts/essays/section.html index d7075c5f..36331fbf 100644 --- a/layouts/essays/section.html +++ b/layouts/essays/section.html @@ -3,9 +3,11 @@ {{ partial "header.html" . }}
{{ .Content }}
+ {{ $pages := .Pages }} + {{ partial "section-categories" $pages }} {{ $remainingMonthsToOpen := 3 }} - {{ range (where site.RegularPages "Type" "eq" "essays").GroupByDate "2006" -}} + {{ range $pages.GroupByDate "2006" -}}
{{ partial "components/section-title" (dict "Left" .Key diff --git a/layouts/posts/page.html b/layouts/posts/page.html index 0320820d..e093e810 100644 --- a/layouts/posts/page.html +++ b/layouts/posts/page.html @@ -1,49 +1,3 @@ {{ define "main" }} -
- -
- {{ if .Params.banner }} - {{ partial "components/logo" (dict - "class" "block round-sticker w-14 h-14 lg:w-28 lg:h-28 right-2 lg:-right-20 top-2 lg:top-4 absolute rotate-[3.0deg]" - "imageClass" "block w-full" - ) }} - {{ else }} - {{ partial "components/logo" (dict - "class" "block w-[10rem]" - "imageClass" "block w-full" - ) }} - {{ end }} - - {{ partial "posts/banner" . }} - -

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

- -
- {{ partial "components/date" . }} - {{ if or .Params.categories .Params.tags }}·{{ end }} - {{ partial "components/category-pill" . }} - {{ partial "components/tags" . }} -
-
- - -
- {{ partial "posts/toc" . }} -
{{ .Content }}
- {{ partial "posts/endnotes" . }} -
- - {{ partial "posts/action-menu.html" . }} - {{ partial "posts/now-read-this.html" . }} - {{ partial "components/back-to-top.html" . }} -
+ {{ partial "template/post-page" . }} {{ end }} diff --git a/layouts/section.html b/layouts/section.html index d3fe3ac4..3ddc6bb7 100644 --- a/layouts/section.html +++ b/layouts/section.html @@ -1,11 +1,19 @@ {{ define "main" }} + + {{ $pages := .Pages }} + {{ $categories := slice }} +
{{ partial "header.html" . }}
{{ .Content }}
+ + {{ partial "section-categories" $pages }} +

*稻草人周刊也属于散文集,但为了方便查阅,周刊没有列在下面,请到分类页面查看周刊。

+ {{ $remainingMonthsToOpen := 3 }} - {{ range (where site.RegularPages "Type" "eq" "posts").GroupByDate "2006" -}} + {{ range $pages.GroupByDate "2006" -}}
{{ partial "components/section-title" (dict "Left" .Key @@ -13,20 +21,30 @@ )}} {{ range .Pages.GroupByDate "January" }} -
- -

- {{ .Key }} - {{ T "archivePage.postCountMonthly" (len .Pages) }} -

-
+
+

+ {{ .Key }} +

-
+
{{ $remainingMonthsToOpen = sub $remainingMonthsToOpen 1 }} {{ end }}
-- cgit v1.2.3