From ef16dffd81595af3bc03efea78d45032d0b467a2 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Tue, 15 Jul 2025 16:47:25 +0800 Subject: refactor: replace _card.scss with UnoCSS --- layouts/_partials/components/tags.html | 2 +- layouts/_partials/home/latest-cards.html | 8 +++++--- layouts/_partials/items/card.html | 10 +++++----- layouts/_shortcodes/card.html | 23 ++--------------------- layouts/cards/section.html | 4 ++-- layouts/cards/single.html | 14 +++++++++----- 6 files changed, 24 insertions(+), 37 deletions(-) (limited to 'layouts') diff --git a/layouts/_partials/components/tags.html b/layouts/_partials/components/tags.html index 6ff7f594..b08230d9 100644 --- a/layouts/_partials/components/tags.html +++ b/layouts/_partials/components/tags.html @@ -1,3 +1,3 @@ {{ range .Params.tags }} -#{{ . }} +#{{ . }} {{ end }} diff --git a/layouts/_partials/home/latest-cards.html b/layouts/_partials/home/latest-cards.html index bad3a27e..78a8a515 100644 --- a/layouts/_partials/home/latest-cards.html +++ b/layouts/_partials/home/latest-cards.html @@ -1,11 +1,13 @@ {{ if eq .Site.Language.Lang "zh" }} -
-
+
+
{{- $cards := .Site.GetPage "section" "cards" }} {{- $paginator := .Paginate $cards.Pages 4 }} {{- range $paginator.Pages }} - {{ partial "items/card" (dict "context" . "summary" true) }} +
+ {{ partial "items/card" (dict "context" . "summary" true) }} +
{{- end }}
diff --git a/layouts/_partials/items/card.html b/layouts/_partials/items/card.html index b8a3c7c1..b66bf676 100644 --- a/layouts/_partials/items/card.html +++ b/layouts/_partials/items/card.html @@ -1,18 +1,18 @@ {{ $ctx := .context }} {{ $showSummary := .summary }} -
-

- {{ $ctx.Title }} + {{ $ctx.Title }}

-
{{ partial "components/tags" $ctx }}
+
{{ partial "components/tags" $ctx }}
-
+
{{ if $showSummary }}{{ $ctx.Summary }}{{ else }}{{ $ctx.Content }}{{ end }}
diff --git a/layouts/_shortcodes/card.html b/layouts/_shortcodes/card.html index a860b72c..e98d50ba 100644 --- a/layouts/_shortcodes/card.html +++ b/layouts/_shortcodes/card.html @@ -2,27 +2,8 @@ {{- $hideHeader := .Get 1 | default "false" | lower -}} {{- if $card }} -
- - - {{- if ne $hideHeader "true" }} -
-

{{ $card.Title }}

- {{- if $card.Params.tags }} -

- {{- range $card.Params.tags }} - #{{ . }} - {{- end }} -

- {{- end }} -
- {{- end }} - -
- {{- with $card.Content }} - {{ . }} - {{- end }} -
+
+ {{ partial "items/card" (dict "context" $card) }}
{{- else }}

⚠️ 无法找到卡片: {{ .Get 0 }}

diff --git a/layouts/cards/section.html b/layouts/cards/section.html index 89ec474b..58ae859c 100644 --- a/layouts/cards/section.html +++ b/layouts/cards/section.html @@ -6,13 +6,13 @@ {{- $pages := $cards.Pages }} {{- $featured := first 6 $pages }} {{- $rest := after 6 $pages }} -
+
{{- range $featured }} {{ partial "items/card" (dict "context" . "summary" true) }} {{- end }}
-
    +
      {{- range $rest }}
    • {{ .Title }} diff --git a/layouts/cards/single.html b/layouts/cards/single.html index 0b269bca..3ff2c5eb 100644 --- a/layouts/cards/single.html +++ b/layouts/cards/single.html @@ -1,6 +1,10 @@ {{ define "main" }} -
      - {{ partial "components/logo" (dict "link" "cards") }} +
      + {{ partial "components/logo" (dict + "link" "cards" + "class" "round-sticker absolute top-[-1rem] right-[-1rem] w-[4rem] h-[4rem] z-1 rotate-[-5deg]" + "imageClass" "w-full" + ) }} {{ partial "items/card" (dict "context" .) }} {{- /* 查询引用了这个卡片的文章 */ -}} @@ -15,9 +19,9 @@ {{- /* 如果有文章引用这个卡片,就显示它们 */ -}} {{ if gt (len $referencedBy) 0 }} -
      -

      引用了本卡片的文章

      -
        +
        +

        引用了本卡片的文章

        +