From f312afd11e292b6ccd5cc3767b1be08aaf4f1495 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 20 Aug 2025 20:19:32 +0800 Subject: feat: add filters to term page - refactor term page structure with partials - add "reverse order" button - add "hide weekly posts" button - i18n support --- i18n/en.yml | 3 ++ i18n/zh.yml | 3 ++ layouts/_partials/items/post-small.html | 4 +- layouts/_partials/term/term-books.html | 9 +++++ layouts/_partials/term/term-cards.html | 11 +++++ layouts/_partials/term/term-header.html | 34 ++++++++++++++++ layouts/_partials/term/term-posts.html | 6 +++ layouts/_partials/term/term-scripts.html | 69 ++++++++++++++++++++++++++++++++ layouts/term.html | 58 ++++----------------------- static/img/clockwork.svg | 6 +++ static/img/crow.svg | 6 +++ 11 files changed, 158 insertions(+), 51 deletions(-) create mode 100644 layouts/_partials/term/term-books.html create mode 100644 layouts/_partials/term/term-cards.html create mode 100644 layouts/_partials/term/term-header.html create mode 100644 layouts/_partials/term/term-posts.html create mode 100644 layouts/_partials/term/term-scripts.html create mode 100644 static/img/clockwork.svg create mode 100644 static/img/crow.svg diff --git a/i18n/en.yml b/i18n/en.yml index 69174498..8c49e8ec 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -29,3 +29,6 @@ library: viewAllThisYear: All Books This Year back2top: I'll take you up! emailMe: If you prefer one-on-one communication, or just want to say hello, feel free to email me at +termFilterButton: + hideWeekly: I'll deal with scarecrows. + reverseOrder: Push to reverse time. diff --git a/i18n/zh.yml b/i18n/zh.yml index b0147949..718e131f 100644 --- a/i18n/zh.yml +++ b/i18n/zh.yml @@ -30,3 +30,6 @@ library: viewAllThisYear: 查看今年完整书单 back2top: 我带你上去! emailMe: 如果你偏好一对一的沟通,或者只是想打个招呼,欢迎发邮件到 +termFilterButton: + hideWeekly: 我帮你解决稻草人 + reverseOrder: 按下以逆转时间 diff --git a/layouts/_partials/items/post-small.html b/layouts/_partials/items/post-small.html index 644cb106..3113ba2b 100644 --- a/layouts/_partials/items/post-small.html +++ b/layouts/_partials/items/post-small.html @@ -1,4 +1,6 @@ -
  • +{{ $isWeekly := (eq .Params.categories "稻草人周刊") }} +
  • {{ .Title }}{{ with .Params.subtitle }}:{{. }} {{ end }} diff --git a/layouts/_partials/term/term-books.html b/layouts/_partials/term/term-books.html new file mode 100644 index 00000000..5af0a77a --- /dev/null +++ b/layouts/_partials/term/term-books.html @@ -0,0 +1,9 @@ +{{ $books := where .Pages "Section" "eq" "library" }} +{{ if gt (len $books) 0 }} +

    {{ T "termPage.books" }}

    +
    + {{ range $books }} + {{ partial "items/book" . }} + {{ end }} +
    +{{ end }} diff --git a/layouts/_partials/term/term-cards.html b/layouts/_partials/term/term-cards.html new file mode 100644 index 00000000..f9cd4c1a --- /dev/null +++ b/layouts/_partials/term/term-cards.html @@ -0,0 +1,11 @@ +{{ $cards := where .Pages "Section" "eq" "cards" }} +{{ if gt (len $cards) 0 }} +

    {{ T "termPage.cards" }}

    +
    +
    + {{ range $cards }} + {{ partial "items/card" (dict "context" . "summary" true) }} + {{ end }} +
    +
    +{{ end }} diff --git a/layouts/_partials/term/term-header.html b/layouts/_partials/term/term-header.html new file mode 100644 index 00000000..e0501b65 --- /dev/null +++ b/layouts/_partials/term/term-header.html @@ -0,0 +1,34 @@ +
    +

    + +
    + {{ if or (hasPrefix .Page.Params.icon "http://") (hasPrefix .Page.Params.icon "https://") }} + {{ .Page.LinkTitle }} + {{ else }} + {{ .Page.Params.icon }} + {{ end }} + {{ if and (eq .Data.Singular "tag") (not .Params.icon) }}#{{ end }} + {{ .Title }} +
    + +
    + {{ if eq .Data.Singular "tag" }} + + {{ end }} + +
    +

    + {{ with .Params.description | markdownify }} +

    {{ . }}

    + {{ end }} +
    diff --git a/layouts/_partials/term/term-posts.html b/layouts/_partials/term/term-posts.html new file mode 100644 index 00000000..86e1b350 --- /dev/null +++ b/layouts/_partials/term/term-posts.html @@ -0,0 +1,6 @@ +
      + {{ range where .Pages "Section" "not in" (slice "cards" "library") }} + {{ partial "items/post-small" . }} + {{ end }} +
    diff --git a/layouts/_partials/term/term-scripts.html b/layouts/_partials/term/term-scripts.html new file mode 100644 index 00000000..b061794a --- /dev/null +++ b/layouts/_partials/term/term-scripts.html @@ -0,0 +1,69 @@ + + +{{ if eq .Data.Singular "tag" }} + +{{ end }} diff --git a/layouts/term.html b/layouts/term.html index ffdbdf95..ca87a2a2 100644 --- a/layouts/term.html +++ b/layouts/term.html @@ -2,55 +2,13 @@
    {{ partial "header" . }} {{ partial "home/home-nav" . }} -
    -

    - {{ if or (hasPrefix .Page.Params.icon "http://") (hasPrefix .Page.Params.icon "https://") }} - - {{ .Page.LinkTitle }} - - {{ else }} - {{ .Page.Params.icon }} - {{ end }} - {{ if and (eq .Data.Singular "tag") (not .Params.icon) }}#{{ end }}{{ .Title }} -

    - {{ with .Params.description | markdownify }} -

    {{ . }}

    - {{ end }} -
    -
    - -
      - {{ range where .Pages "Section" "not in" (slice "cards" "library") }} - {{ partial "items/post-small" . }} - {{ end }} -
    - - - {{ $cards := where .Pages "Section" "eq" "cards" }} - {{ if gt (len $cards) 0 }} -

    {{ T "termPage.cards" }}

    -
    -
    - {{ range $cards }} - {{ partial "items/card" (dict "context" . "summary" true) }} - {{ end }} -
    -
    - {{ end }} - - - {{ $books := where .Pages "Section" "eq" "library" }} - {{ if gt (len $books) 0 }} -

    {{ T "termPage.books" }}

    -
    - {{ range $books }} - {{ partial "items/book" . }} - {{ end }} -
    - {{ end }} -
    + {{ partial "term/term-header" . }} +
    + {{ partial "term/term-posts" . }} + {{ partial "term/term-cards" . }} + {{ partial "term/term-books" . }} +
    - {{ partial "footer.html" . }} + {{ partial "term/term-scripts" . }} + {{ partial "footer" . }} {{ end }} diff --git a/static/img/clockwork.svg b/static/img/clockwork.svg new file mode 100644 index 00000000..5c3db302 --- /dev/null +++ b/static/img/clockwork.svg @@ -0,0 +1,6 @@ + + + +clockwork + + \ No newline at end of file diff --git a/static/img/crow.svg b/static/img/crow.svg new file mode 100644 index 00000000..dca15f56 --- /dev/null +++ b/static/img/crow.svg @@ -0,0 +1,6 @@ + + + +raven + + \ No newline at end of file -- cgit v1.2.3