From fae7d31c6a04654d1682aa2d0b6f88f7ec2caf4e Mon Sep 17 00:00:00 2001 From: razonyang Date: Thu, 31 Aug 2023 20:29:54 +0800 Subject: [PATCH] feat(article-cards): add the linkText parameter Make the entire card clickable when empty --- layouts/partials/bootstrap/article-cards.html | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/layouts/partials/bootstrap/article-cards.html b/layouts/partials/bootstrap/article-cards.html index 374e779..0f5f7c0 100644 --- a/layouts/partials/bootstrap/article-cards.html +++ b/layouts/partials/bootstrap/article-cards.html @@ -1,28 +1,33 @@ {{- $summaryLen := 120 }} {{- $limit := 12 }} {{- $sections := slice }} +{{- $linkText := i18n "read_more" }} {{- if .IsNamedParams }} {{- with .Get "limit" }}{{ $limit = . }}{{ end }} {{- with .Get "summaryLen" }}{{ $summaryLen = . }}{{ end }} {{- with .Get "sections" }}{{ $sections = split . "," }}{{ end }} + {{- if isset .Params "linkText" }}{{ $linkText = .Get "linkText" }}{{ end }} {{- end }} {{- $pages := site.RegularPages }} {{- with $sections }} {{- $pages = where $pages "Section" "in" . }} {{- end }} -
+
{{- range first $limit $pages }} -
-
+ {{- if $linkText }} + {{ print `
` | safeHTML }} + {{- else }} + {{ printf `` .RelPermalink .Title | safeHTML }} + {{- end }} +
{{- with .FirstSection }} - + {{- .Title -}} - + {{- end }} + class="z-1 badge text-bg-secondary position-absolute fw-normal top-0 end-0 me-1 mt-1"> {{- .Date | time.Format ":date_medium" -}} {{- $img := partial "images/functions/page-thumbnail" (dict @@ -41,24 +46,30 @@
{{- end }} -
+ {{- if $linkText }} + {{ print `
` | safeHTML }} + {{- else }} + {{ print "" | safeHTML }} + {{- end }} {{- end }}