From 154e559b13f87cd220fa3dfdca3ab5a3c072a61d Mon Sep 17 00:00:00 2001 From: Eltrac Date: Mon, 7 Apr 2025 15:35:28 +0800 Subject: feat: latest card section in index page Former-commit-id: fb7259d515305b6e4b5262d132ef06b31300c8db --- assets/css/components/_card.scss | 13 +++++ assets/css/components/_postlist.scss | 24 +++++++++ i18n/en.yml | 1 + i18n/zh.yml | 1 + layouts/index.html | 96 +++++++++++++++++++++++++----------- 5 files changed, 105 insertions(+), 30 deletions(-) diff --git a/assets/css/components/_card.scss b/assets/css/components/_card.scss index 9dd10d32..43a25ca4 100644 --- a/assets/css/components/_card.scss +++ b/assets/css/components/_card.scss @@ -82,3 +82,16 @@ } } } + +#latest-cards { + .latest-cards-container { + display: flex; + width: 100%; + overflow-x: auto; + gap: 1rem; + .card { + flex-shrink: 0; + width: 50%; + } + } +} diff --git a/assets/css/components/_postlist.scss b/assets/css/components/_postlist.scss index f2f5c212..87a68026 100644 --- a/assets/css/components/_postlist.scss +++ b/assets/css/components/_postlist.scss @@ -1,3 +1,11 @@ +.index-section-title { + font-size: 1.1rem; + margin-bottom: 0; + font-weight: normal; +} + +/* Post List Styles */ + .posts-list { display: flex; flex-direction: column; @@ -110,3 +118,19 @@ display: inline-block; } } + +/* Card List Styles */ + +#latest-cards { + margin: 1rem 0; + .latest-cards-container { + display: flex; + width: 100%; + overflow-x: auto; + gap: 1rem; + .card { + flex-shrink: 0; + width: 50%; + } + } +} diff --git a/i18n/en.yml b/i18n/en.yml index cb40236c..e8b32709 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -14,3 +14,4 @@ postNav: latest: 'Latest' categories: 'Categories' tags: 'Tags' +cards: Cards diff --git a/i18n/zh.yml b/i18n/zh.yml index f8e4a3ca..6c66fe75 100644 --- a/i18n/zh.yml +++ b/i18n/zh.yml @@ -14,3 +14,4 @@ postNav: latest: '最新' categories: '分类' tags: '标签' +cards: 最近在学 diff --git a/layouts/index.html b/layouts/index.html index 99323bee..3a7a29ba 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,41 +1,77 @@ {{ define "main" }} -
+
{{ partial "header.html" . }} {{ partial "components/postnav.html" . }} -
- {{ $firstPost := true }} - {{ range first 8 (where site.RegularPages "Type" "in" site.Params.mainSections) }} -
-
-
- - - {{ .Title }} + + +
+
+ {{ $firstPost := true }} + {{ range first 8 (where site.RegularPages "Type" "in" site.Params.mainSections) }} +
+
+
+ + + {{ .Title }} + +
+ {{ with .Params.categories }} + + {{ end }} +
+ + {{ if $firstPost }} +
+ {{ .Summary }} +
+ {{ $firstPost = false }} + {{ end }} +
+ {{ end }} +
+ 查看所有 +
+ + {{ if eq .Site.Language.Lang "zh" }} + +
+

{{ T "cards" }}

+
+ {{- $cards := .Site.GetPage "section" "cards" }} + {{- $paginator := .Paginate $cards.Pages 4 }} + {{- range $paginator.Pages }} +
+
+

+ {{ .Title }}

+ {{- if .Params.tags }} +

+ {{- range .Params.tags }} + #{{ . }} + {{- end }} +

+ {{- end }}
- {{ with .Params.categories }} - - {{ end }} -
- - {{ if $firstPost }} -
+ +
{{ .Summary }}
- {{ $firstPost = false }} - {{ end }} +
+ {{- end }}
- {{ end }} -
- 查看所有 + + {{ end }}
{{ partial "footer.html" . }} {{ end }} -- cgit v1.2.3