diff --git a/.prettierignore b/.prettierignore index c128736f..30e754c9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -28,9 +28,6 @@ static layouts/_default/_markup/render-heading.html layouts/_default/index.json layouts/_default/list.html -layouts/partials/article-link/card-related.html -layouts/partials/article-link/card.html -layouts/partials/article-link/simple.html layouts/partials/hero/background.html layouts/shortcodes/screenshot.html layouts/shortcodes/figure.html diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index 41e89f8b..11045624 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -1,44 +1,45 @@ -
- - {{- with $.Params.images -}} +
+ {{- with $.Params.images -}} {{- range first 6 . }} - {{ end -}} - {{- else -}} - {{ $images := $.Resources.ByType "image" }} - {{ $featuredImage := $images.GetMatch "*feature*" }} - {{ if not $featuredImage }} - {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} - {{ end }} - {{ if and (not $featuredImage) .Params.featureimage }} - {{ $featuredImage = resources.GetRemote .Params.featureimage }} - {{ end }} - {{ if not $featuredImage }} - {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} - {{ end }} - {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} - {{ $featuredImage = $featuredImage.Resize "600x" }} - {{ end }} - {{ with $featuredImage }} - {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} - - {{ else }} - {{ with $.Site.Params.images }} - + + {{ end -}} + {{- else -}} + {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end }} + {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} + + {{ else }} + {{ with $.Site.Params.images }} + {{ end }} {{ end }} {{ end }} - {{ if and .Draft .Site.Params.article.showDraftLabel }} + {{ if and .Draft .Site.Params.article.showDraftLabel }} {{ partial "badge.html" (i18n "article.draft" | emojify) }} - {{ end }} + {{ end }} - + diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index 97390da8..70affad0 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -1,48 +1,48 @@ -
- - {{- with $.Params.images -}} +
+ {{- with $.Params.images -}} {{- range first 6 . }} - {{ end -}} - {{- else -}} - {{ $images := $.Resources.ByType "image" }} - {{ $featuredImage := $images.GetMatch "*feature*" }} - {{ if not $featuredImage }} - {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} - {{ end }} - {{ if and (not $featuredImage) .Params.featureimage }} - {{ $featuredImage = resources.GetRemote .Params.featureimage }} - {{ end }} - {{ if not $featuredImage }} - {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} - {{ end }} - {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} - {{ $featuredImage = $featuredImage.Resize "600x" }} - {{ end }} - {{ if .Params.hideFeatureImage }} - {{ $featuredImage = false }} - {{ end }} - {{ with $featuredImage }} - {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} -
- {{ else }} - {{ with $.Site.Params.images }} - + + {{ end -}} + {{- else -}} + {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end }} + {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ if .Params.hideFeatureImage }} + {{ $featuredImage = false }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+ {{ else }} + {{ with $.Site.Params.images }} + {{ end }} {{ end }} {{ end }} - - {{ if and .Draft .Site.Params.article.showDraftLabel }} + {{ if and .Draft .Site.Params.article.showDraftLabel }} {{ partial "badge.html" (i18n "article.draft" | emojify) }} - {{ end }} + {{ end }} -
+ diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 269b990b..9f0ab86d 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -2,67 +2,68 @@ {{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }} {{ if .Site.Params.list.showCards }} -{{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }} + {{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }} {{ else }} -{{ $articleClasses = delimit (slice $articleClasses "") " " }} + {{ $articleClasses = delimit (slice $articleClasses "") " " }} {{ end }} {{ $articleImageClasses := "w-full md:w-auto h-full thumbnail nozoom" }} {{ if .Site.Params.list.showCards }} -{{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }} + {{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }} {{ else }} -{{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }} + {{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }} {{ end }} {{ $articleInnerClasses := "" }} {{ if .Site.Params.list.showCards }} -{{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }} + {{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }} {{ else }} -{{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }} + {{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }} {{ end }} {{ if $constrainItemsWidth }} -{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }} + {{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }} {{ end }} - {{- with $.Params.images -}} + {{- with $.Params.images -}} {{- range first 6 . }} - {{ end -}} - {{- else -}} - {{ $images := $.Resources.ByType "image" }} - {{ $featuredImage := $images.GetMatch "*feature*" }} - {{ if not $featuredImage }} - {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} - {{ end }} - {{ if and (not $featuredImage) .Params.featureimage }} - {{ $featuredImage = resources.GetRemote .Params.featureimage }} - {{ end }} - {{ if not $featuredImage }} - {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} - {{ end }} - {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} - {{ $featuredImage = $featuredImage.Resize "600x" }} - {{ end }} - {{ if .Params.hideFeatureImage }} - {{ $featuredImage = false }} - {{ end }} - {{ with $featuredImage }} - {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} -
- {{ else }} - {{ with $.Site.Params.images }} - - {{ end }} + + {{ end -}} + {{- else -}} + {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end }} + {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ if .Params.hideFeatureImage }} + {{ $featuredImage = false }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+ {{ else }} + {{ with $.Site.Params.images }} + {{ end }} {{ end }} + {{ end }} -
+