Skip to content

Commit

Permalink
feat(article-cards): add the item-attr-* parameters for attaching att…
Browse files Browse the repository at this point in the history
…ributes on elements
  • Loading branch information
razonyang committed Sep 19, 2023
1 parent a6fca8f commit 7afc9ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions layouts/partials/bootstrap/article-cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
{{- $limit := 12 }}
{{- $sections := slice }}
{{- $linkText := i18n "read_more" }}
{{- $itemAttrs := slice }}
{{- 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 }}
{{- $itemAttrs = partial "bootstrap/functions/attributes" (dict "Params" .Params "Prefix" "item-attr") }}
{{- end }}
{{- $pages := site.RegularPages }}
{{- with $sections }}
{{- $pages = where $pages "Section" "in" . }}
{{- end }}
{{- $itemAttrsStr := "" }}
{{ with $itemAttrs }}{{ $itemAttrsStr = delimit . " " | printf " %s" }}{{ end }}
<div class="row g-4 row-cols-1 row-cols-md-2 row-cols-lg-3 mb-5">
{{- range first $limit $pages }}
{{- if $linkText }}
{{ print `<div class="col">` | safeHTML }}
{{ printf `<div class="col"%s>` $itemAttrsStr | safeHTML }}
{{- else }}
{{ printf `<a class="col text-decoration-none" href="%s" title="%s">` .RelPermalink .Title | safeHTML }}
{{ printf `<a class="col text-decoration-none" href="%s" title="%s"%s>` .RelPermalink .Title $itemAttrsStr | safeHTML }}
{{- end }}
<div class="card shadow h-100 w-100 position-relative">
{{- with .FirstSection }}
Expand Down

0 comments on commit 7afc9ac

Please sign in to comment.