mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
refactor(article-link): separate Go templates from HTML rendering
Add descriptions for the purpose of each template. It takes time to figure out their use every time.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
{{/* Used by
|
||||
1. article shortcode
|
||||
*/}}
|
||||
{{ $target := .target }}
|
||||
{{ $shortcodeShowSummary := .showSummary }}
|
||||
{{ $shortcodeCompactSummary := .compactSummary }}
|
||||
@@ -29,30 +32,33 @@
|
||||
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
|
||||
{{ end }}
|
||||
|
||||
{{ $images := $target.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ $featuredURL := "" }}
|
||||
{{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end }}
|
||||
{{ if and $target.Params.featureimage (not $featured) }}
|
||||
{{ $url:= $target.Params.featureimage }}
|
||||
{{ $featured = resources.GetRemote $url }}
|
||||
{{ end }}
|
||||
{{ if not $featured }}
|
||||
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
|
||||
{{ end }}
|
||||
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
|
||||
{{ with $featured }}
|
||||
{{ $featuredURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $featuredURL = (.Resize "600x").RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<div class="{{ $articleClasses }}">
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" $target | safeHTMLAttr }}
|
||||
class="absolute inset-0"
|
||||
aria-label="{{ $.Title }}"></a>
|
||||
|
||||
{{ $images := $target.Resources.ByType "image" }}
|
||||
{{ $featured := $images.GetMatch "*feature*" }}
|
||||
{{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end }}
|
||||
{{ if and $target.Params.featureimage (not $featured) }}
|
||||
{{ $url:= $target.Params.featureimage }}
|
||||
{{ $featured = resources.GetRemote $url }}
|
||||
{{ end }}
|
||||
{{ if not $featured }}
|
||||
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
|
||||
{{ end }}
|
||||
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
|
||||
{{ with $featured }}
|
||||
{{ $featuredURL := .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $featuredURL = (.Resize "600x").RelPermalink }}
|
||||
{{ end }}
|
||||
<div class="{{ $articleImageClasses }}" style="background-image:url({{ $featuredURL }});"></div>
|
||||
{{ with $featuredURL }}
|
||||
<div class="{{ $articleImageClasses }}" style="background-image:url({{ . }});"></div>
|
||||
{{ end }}
|
||||
<div class="{{ $articleInnerClasses }}">
|
||||
<div class="items-center text-start text-xl font-semibold">
|
||||
|
||||
Reference in New Issue
Block a user