From 59d0d0569dba5b05f30dbf743920ac4fa99dd4f7 Mon Sep 17 00:00:00 2001 From: eltrac Date: Sun, 13 Sep 2026 17:41:13 +0800 Subject: home: rework homepage design --- layouts/_partials/home/latest-posts.html | 18 ++--- layouts/_partials/home/selected-works.html | 118 +++++++++++++++++++++++++++++ layouts/_partials/taxonomy/pagefind.html | 4 + layouts/home.html | 22 ++++-- layouts/view_postblock_home.html | 45 +++++++++++ 5 files changed, 191 insertions(+), 16 deletions(-) create mode 100644 layouts/_partials/home/selected-works.html create mode 100644 layouts/view_postblock_home.html diff --git a/layouts/_partials/home/latest-posts.html b/layouts/_partials/home/latest-posts.html index 6115cac..b86a4c5 100644 --- a/layouts/_partials/home/latest-posts.html +++ b/layouts/_partials/home/latest-posts.html @@ -1,14 +1,10 @@ -
- {{ $firstPost := true }} - - {{ range first 12 (where site.RegularPages "Type" "in" site.Params.mainSections) }} - {{ if $firstPost }} - {{ .Render "view_postblock_summary" }} - {{ else }} - {{ .Render "view_postblock" }} - {{ end }} - - {{ $firstPost = false }} +
+ {{ $postsn := 8 }} + {{ if eq .Site.Language.Lang "zh" }} + {{ $postsn = 1 }} + {{ end }} + {{ range first $postsn (where site.RegularPages "Type" "in" site.Params.mainSections) }} + {{ .Render "view_postblock_home" }} {{ end }}
diff --git a/layouts/_partials/home/selected-works.html b/layouts/_partials/home/selected-works.html new file mode 100644 index 0000000..4a744ad --- /dev/null +++ b/layouts/_partials/home/selected-works.html @@ -0,0 +1,118 @@ + +
+

Selected works

+ {{ $selectedTags := (slice "精选") }} + {{ range first 3 (shuffle (where site.RegularPages "Params.tags" "intersect" $selectedTags)) }} +
+

+ {{ .LinkTitle }} +

+ + {{ $tags := first 3 (complement $selectedTags .Params.tags) }} + {{ $context := dict "Params" (dict "tags" $tags) }} + {{ partial "components/tags" $context }} + +
+ {{ end }} + 全部精选 → +
+ +
+ +
+
+ {{ $articles := where site.RegularPages "Section" "eq" "article" }} +
+

Tech Stuff

+ {{ $techCategories := (slice "代码炼金术" "软件杂谈" "茶歇蔻芥")}} + {{ $tech := where $articles "Params.categories" "in" $techCategories }} +
    + {{ range first 6 $tech }} +
  1. {{ .LinkTitle }}
  2. + {{ end }} +
      +
+
+

General Posts

+ {{ $general := where $articles "Params.categories" "not in" $techCategories }} +
    + {{ range first 6 $general }} +
  1. {{ .LinkTitle }}
  2. + {{ end }} +
      +
+ {{ $weekly := where site.RegularPages "Section" "eq" "weekly" }} +
+

+ Weekly + * +

+
    + {{ range first 6 $weekly }} +
  1. + {{ .LinkTitle }} +
  2. + {{ end }} +
      +
+ {{ $fiction := where site.Pages "Section" "eq" "fiction" }} +
+

+ Fictions +

+
    + {{ range first 6 $fiction }} +
  1. + {{ .LinkTitle }} +
  2. + {{ end }} +
      +
+ +

+ * + 实心圆表示正刊,空心圆表示小报。 +

+
+
+ + +
+ +
+

Bookshelf

+
+ {{ $library := where site.Pages "Section" "eq" "library" }} + {{ $books := where $library "Params.authors" "ne" nil }} + {{ range first 6 $books }} +
+ {{ partial "components/book" (dict "ctx" .) }} +
+ {{ end }} +
+ + 图书馆 → + +
+ + + diff --git a/layouts/_partials/taxonomy/pagefind.html b/layouts/_partials/taxonomy/pagefind.html index 920d36d..2a57181 100644 --- a/layouts/_partials/taxonomy/pagefind.html +++ b/layouts/_partials/taxonomy/pagefind.html @@ -1,2 +1,6 @@ + diff --git a/layouts/home.html b/layouts/home.html index ba5b8ce..6a511bb 100644 --- a/layouts/home.html +++ b/layouts/home.html @@ -1,11 +1,23 @@ {{ define "main" }} {{ partial "home/microformats" . }} -
- {{ partial "home/home-nav" . }} +
{{ partial "home/latest-posts" . }} {{ partial "home/more-links" . }} -
- {{ .Content }} -
+ {{ if eq .Site.Language.Lang "zh" }} +
+ {{ partial "home/selected-works" . }} +
+

Monthly word count

+ {{ partial "stats/word-count-chart" . }} +

极客死亡计划一共发布了 {{ len .Site.RegularPages }} 篇页面,共计 + + {{- $words := 0 -}} + {{- range (where .Site.RegularPages "Section" "!=" "") -}} + {{- $words = add $words .WordCount -}} + {{- end -}} + {{ lang.FormatNumber 0 $words }} + + 字。

+ {{ end }}
{{ end }} diff --git a/layouts/view_postblock_home.html b/layouts/view_postblock_home.html new file mode 100644 index 0000000..3d78249 --- /dev/null +++ b/layouts/view_postblock_home.html @@ -0,0 +1,45 @@ + + +
+
+
+

+ Recently + in {{ .Section }} + +

+

+ + {{ if eq .Section "library" }} + 读《{{ .Title }}》 + {{ else }} + {{ .Title }} + {{ end }} + + {{ if eq .Section "fictions" }} + 小说 + {{ end }} +

+
+ + {{ $ctx := . }} + {{ with .Params.categories }} +
+ {{ partial "components/category-pill" $ctx }} +
+ {{ end }} +
+
+ +
+ {{ if .Params.description }} + {{ .Params.description }} + {{ else }} + {{ .Summary }} + {{ end }} +
-- cgit v1.2.3