Merge pull request #2451 from ZhenShuo2021/feat/image-process

 Feat(article-link, hero): improve image handling
This commit is contained in:
Nuno C.
2025-09-16 11:10:04 +01:00
committed by GitHub
11 changed files with 310 additions and 309 deletions

View File

@@ -2543,13 +2543,6 @@ body.zen-mode-enable {
} }
} }
} }
.group-hover\:underline-offset-2 {
&:is(:where(.group):hover *) {
@media (hover: hover) {
text-underline-offset: 2px;
}
}
}
.group-hover\:opacity-100 { .group-hover\:opacity-100 {
&:is(:where(.group):hover *) { &:is(:where(.group):hover *) {
@media (hover: hover) { @media (hover: hover) {
@@ -2640,6 +2633,18 @@ body.zen-mode-enable {
border-top-color: transparent; border-top-color: transparent;
} }
} }
.before\:absolute {
&::before {
content: var(--tw-content);
position: absolute;
}
}
.before\:inset-0 {
&::before {
content: var(--tw-content);
inset: calc(var(--spacing) * 0);
}
}
.after\:clear-both { .after\:clear-both {
&::after { &::after {
content: var(--tw-content); content: var(--tw-content);
@@ -3239,11 +3244,6 @@ body.zen-mode-enable {
display: inline; display: inline;
} }
} }
.ltr\:text-right {
&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
text-align: right;
}
}
.rtl\:left-0 { .rtl\:left-0 {
&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
left: calc(var(--spacing) * 0); left: calc(var(--spacing) * 0);
@@ -3855,9 +3855,6 @@ pre {
text-decoration-thickness: 3px; text-decoration-thickness: 3px;
text-underline-offset: 4px; text-underline-offset: 4px;
} }
.group-hover-card:hover:has(.group-hover-cancel:hover) .group-hover-card-title {
text-decoration: none !important;
}
@layer base { @layer base {
[type='text'],input:where(:not([type])),[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select { [type='text'],input:where(:not([type])),[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select {
appearance: none; appearance: none;

View File

@@ -278,8 +278,3 @@ pre {
text-decoration-thickness: 3px; text-decoration-thickness: 3px;
text-underline-offset: 4px; text-underline-offset: 4px;
} }
/* Cancel group hover if .group-hover-card contains .group-hover-cancel*/
.group-hover-card:hover:has(.group-hover-cancel:hover) .group-hover-card-title {
text-decoration: none !important;
}

View File

@@ -1,10 +1,13 @@
{{/* Used by
1. article shortcode
*/}}
{{ $target := .target }} {{ $target := .target }}
{{ $shortcodeShowSummary := .showSummary }} {{ $shortcodeShowSummary := .showSummary }}
{{ $shortcodeCompactSummary := .compactSummary }} {{ $shortcodeCompactSummary := .compactSummary }}
{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }} {{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
{{ $disableImageOptimization := site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := site.Params.disableImageOptimization | default false }}
{{ $articleClasses := "group-hover-card group flex flex-wrap md:flex-nowrap article relative" }} {{ $articleClasses := "flex flex-wrap md:flex-nowrap article relative" }}
{{ if site.Params.list.showCards }} {{ 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 }} {{ else }}
@@ -29,67 +32,55 @@
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }} {{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
{{ end }} {{ end }}
{{ $featured := "" }}
<div class="{{ $articleClasses }}"> {{ $featuredURL := "" }}
<a {{ if not $target.Params.hideFeatureImage }}
{{ partial "article-link/_external-link.html" $target | safeHTMLAttr }} {{ with $target.Params.featureimage }}
class="absolute inset-0" {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
aria-label="{{ $.Title }}"></a> {{ $featured = resources.GetRemote . }}
{{ else }}
{{- with $target.Params.images -}} {{ $featured = resources.Get . }}
{{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}">
{{ end -}}
{{- else -}}
{{- $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 }} {{ end }}
{{- if not $featured }} {{ end }}
{{ if not $featured }}
{{ $images := $target.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }} {{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end -}} {{ end }}
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{ end }}
{{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} {{ with $featured }}
{{ with . }} {{ $featuredURL = .RelPermalink }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ end }} {{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ else }} {{ end }}
{{ with .Resize "600x" }} {{ end }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> {{ end }}
{{ end }}
{{ end }}
{{- else -}}
{{- with site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end -}}
{{- end -}}
{{- end -}}
<article class="{{ $articleClasses }}">
{{ with $featuredURL }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ . }});"></div>
{{ end }}
<div class="{{ $articleInnerClasses }}"> <div class="{{ $articleInnerClasses }}">
<div class="items-center text-start text-xl font-semibold"> <header class="items-center text-start text-xl font-semibold">
{{ with $target.Params.externalUrl }} <a
<div> {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
<div class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> <h2>
{{ $target.Title | emojify }} {{ $target.Title | emojify }}
{{ if $target.Params.externalUrl }}
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500"> <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">&#8599;</span> <span class="rtl:hidden">&#8599;</span>
<span class="ltr:hidden">&#8598;</span> <span class="ltr:hidden">&#8598;</span>
</span> </span>
</div> {{ end }}
</div> </h2>
{{ else }} </a>
<div
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"
href="{{ $target.RelPermalink }}">
{{ $target.Title | emojify }}
</div>
{{ end }}
{{ if and $target.Draft site.Params.article.showDraftLabel }} {{ if and $target.Draft site.Params.article.showDraftLabel }}
<div class="ms-2"> <div class="ms-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
@@ -98,8 +89,8 @@
{{ if templates.Exists "partials/extend-article-link.html" }} {{ if templates.Exists "partials/extend-article-link.html" }}
{{ partial "extend-article-link.html" $target }} {{ partial "extend-article-link.html" $target }}
{{ end }} {{ end }}
</div> </header>
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400"> <div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" $target }} {{ partial "article-meta/basic.html" $target }}
</div> </div>
{{ $showSummary := false }} {{ $showSummary := false }}
@@ -122,4 +113,4 @@
</div> </div>
{{ end }} {{ end }}
</div> </div>
</div> </article>

View File

@@ -1,67 +1,63 @@
{{/* Used by
1. layouts/partials/related.html (related articles in single page)
*/}}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
<div
class="group-hover-card group relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700"> {{ $featured := "" }}
<a {{ $featuredURL := "" }}
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }} {{ with .Params.featureimage }}
class="absolute inset-0" {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
aria-label="{{ $.Title }}"></a> {{ $featured = resources.GetRemote . }}
{{- with $.Params.images -}} {{ else }}
{{- range first 6 . }} {{ $featured = resources.Get . }}
<meta property="og:image" content="{{ . | absURL }}"> {{ end }}
{{ end -}} {{ end }}
{{- else -}}
{{- $images := $.Resources.ByType "image" -}} {{ if not $featured }}
{{- $featured := $images.GetMatch "*feature*" -}} {{ $images := $.Resources.ByType "image" }}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if and .Params.featureimage (not $featured) }} {{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{- $url:= .Params.featureimage -}} {{ end }}
{{ $featured = resources.GetRemote $url }} {{ if not $featured }}
{{ end }} {{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{- if not $featured }} {{ end }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }} {{ end }}
{{ end -}}
{{- with $featured -}} {{ with $featured }}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} {{ $featuredURL = .RelPermalink }}
{{ with . }} {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
<div {{ $featuredURL = (.Resize "600x").RelPermalink }}
class="thumbnail_card_related nozoom w-full" {{ end }}
style="background-image:url({{ .RelPermalink }});"></div> {{ end }}
{{ end }}
{{ else }}
{{ with .Resize "600x" }} <article
<div class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
class="thumbnail_card_related nozoom w-full" {{ with $featuredURL }}
style="background-image:url({{ .RelPermalink }});"></div> <div class="thumbnail_card_related nozoom w-full" style="background-image:url({{ . }});"></div>
{{ end }} {{ end }}
{{ end }}
{{- else -}}
{{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end -}}
{{- end -}}
{{- end -}}
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2"> <span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span> </span>
{{ end }} {{ end }}
<div class="px-6 py-4"> <div class="px-6 py-4">
{{ with .Params.externalUrl }} <header>
<div <a
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
{{ $.Title | emojify }} class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500"> <h2>
<span class="rtl:hidden">&#8599;</span> {{ .Title | emojify }}
<span class="ltr:hidden">&#8598;</span> {{ if .Params.externalUrl }}
</span> <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
</div> <span class="rtl:hidden">&#8599;</span>
{{ else }} <span class="ltr:hidden">&#8598;</span>
<div </span>
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> {{ end }}
{{ .Title | emojify }} </h2>
</div> </a>
{{ end }} </header>
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400"> <div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }} {{ partial "article-meta/basic.html" . }}
</div> </div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
@@ -69,4 +65,4 @@
{{ end }} {{ end }}
</div> </div>
<div class="px-6 pt-4 pb-2"></div> <div class="px-6 pt-4 pb-2"></div>
</div> </article>

View File

@@ -1,64 +1,67 @@
{{/* Used by
1. list.html and term.html (when the cardView option is enabled)
2. Recent articles template (when the cardView option is enabled)
3. Shortcode list.html
*/}}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
<div
class="group-hover-card group relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700"> {{ $featured := "" }}
<a {{ $featuredURL := "" }}
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }} {{ if not .Params.hideFeatureImage }}
class="absolute inset-0" {{ with .Params.featureimage }}
aria-label="{{ $.Title }}"></a> {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{- with $.Params.images -}} {{ $featured = resources.GetRemote . }}
{{- range first 6 . }} {{ else }}
<meta property="og:image" content="{{ . | absURL }}"> {{ $featured = resources.Get . }}
{{ end -}}
{{- else -}}
{{- $images := $.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if and .Params.featureimage (not $featured) }}
{{- $url:= .Params.featureimage -}}
{{ $featured = resources.GetRemote $url }}
{{ end }} {{ end }}
{{- if not $featured }} {{ end }}
{{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }} {{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end -}} {{ end }}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{ end }}
{{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} {{ with $featured }}
{{ with . }} {{ $featuredURL = .RelPermalink }}
<div class="thumbnail_card nozoom w-full" style="background-image:url({{ .RelPermalink }});"></div> {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ end }} {{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ else }} {{ end }}
{{ with .Resize "600x" }} {{ end }}
<div class="thumbnail_card nozoom w-full" style="background-image:url({{ .RelPermalink }});"></div> {{ end }}
{{ end }}
{{ end }}
{{- else -}} <article
{{- with $.Site.Params.images }} class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
<meta property="og:image" content="{{ index . 0 | absURL }}"> {{ with $featuredURL }}
{{ end -}} <div class="thumbnail_card nozoom w-full" style="background-image:url({{ . }});"></div>
{{- end -}} {{ end }}
{{- end -}}
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<span class="absolute top-0 right-0 m-2"> <span class="absolute top-0 right-0 m-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</span> </span>
{{ end }} {{ end }}
<div class="px-6 py-4"> <div class="px-6 py-4">
{{ with .Params.externalUrl }} <header>
<div <a
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
{{ $.Title | emojify }} class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500"> <h2>
<span class="rtl:hidden">&#8599;</span> {{ .Title | emojify }}
<span class="ltr:hidden">&#8598;</span> {{ if .Params.externalUrl }}
</span> <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
</div> <span class="rtl:hidden">&#8599;</span>
{{ else }} <span class="ltr:hidden">&#8598;</span>
<div </span>
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> {{ end }}
{{ .Title | emojify }} </h2>
</div> </a>
{{ end }} </header>
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400"> <div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }} {{ partial "article-meta/basic.html" . }}
</div> </div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
@@ -66,4 +69,4 @@
{{ end }} {{ end }}
</div> </div>
<div class="px-6 pt-4 pb-2"></div> <div class="px-6 pt-4 pb-2"></div>
</div> </article>

View File

@@ -1,6 +1,11 @@
{{/* Used by
1. list.html and term.html (when the cardView option is not enabled)
2. Recent articles template (when the cardView option is not enabled)
3. Shortcode list.html
*/}}
{{ $constrainItemsWidth := .Page.Site.Params.list.constrainItemsWidth | default false }} {{ $constrainItemsWidth := .Page.Site.Params.list.constrainItemsWidth | default false }}
{{ $articleClasses := "group-hover-card group flex flex-wrap md:flex-nowrap article relative" }} {{ $articleClasses := "flex flex-wrap md:flex-nowrap article relative" }}
{{ if .Site.Params.list.showCards }} {{ 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 }} {{ else }}
@@ -27,71 +32,63 @@
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }} {{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
{{ end }} {{ end }}
{{ $featured := "" }}
<div class="{{ $articleClasses }}"> {{ $featuredURL := "" }}
<a {{ if not .Params.hideFeatureImage }}
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }} {{ with .Params.featureimage }}
class="absolute inset-0" {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
aria-label="{{ $.Title }}"></a> {{ $featured = resources.GetRemote . }}
{{- with $.Params.images -}} {{ else }}
{{- range first 6 . }} {{ $featured = resources.Get . }}
<meta property="og:image" content="{{ . | absURL }}">
{{ end -}}
{{- else -}}
{{- $images := $.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if and .Params.featureimage (not $featured) }}
{{- $url:= .Params.featureimage -}}
{{ $featured = resources.GetRemote $url }}
{{ end }} {{ end }}
{{- if not $featured }} {{ end }}
{{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }} {{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end -}} {{ end }}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{ end }}
{{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} {{ with $featured }}
{{ with . }} {{ $featuredURL = .RelPermalink }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> {{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ end }} {{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ else }} {{ end }}
{{ with .Resize "600x" }} {{ end }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> {{ end }}
{{ end }}
{{ end }}
{{- else -}}
{{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end -}}
{{- end -}}
{{- end -}}
<article class="{{ $articleClasses }}">
{{ with $featuredURL }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ . }});"></div>
{{ end }}
<div class="{{ $articleInnerClasses }}"> <div class="{{ $articleInnerClasses }}">
<div class="items-center text-start text-xl font-semibold"> <header class="items-center text-start text-xl font-semibold">
{{ with .Params.externalUrl }} <a
<div {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2"> class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
{{ $.Title | emojify }} <h2>
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">&#8599;</span>
<span class="ltr:hidden">&#8598;</span>
</span>
</div>
{{ else }}
<div
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2">
{{ .Title | emojify }} {{ .Title | emojify }}
</div> {{ if .Params.externalUrl }}
{{ end }} <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">&#8599;</span>
<span class="ltr:hidden">&#8598;</span>
</span>
{{ end }}
</h2>
</a>
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<div class="ms-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</div> <div class="ms-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</div>
{{ end }} {{ end }}
{{ if templates.Exists "partials/extend-article-link.html" }} {{ if templates.Exists "partials/extend-article-link.html" }}
{{ partial "extend-article-link.html" . }} {{ partial "extend-article-link.html" . }}
{{ end }} {{ end }}
</div> </header>
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400"> <div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }} {{ partial "article-meta/basic.html" . }}
</div> </div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
@@ -99,4 +96,4 @@
{{ end }} {{ end }}
</div> </div>
<div class="px-6 pt-4 pb-2"></div> <div class="px-6 pt-4 pb-2"></div>
</div> </article>

View File

@@ -1,16 +1,23 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{- $images := .Resources.ByType "image" -}} {{ $featured := "" }}
{{- $featured := $images.GetMatch "*background*" -}} {{ if .Params.featureimage }}
{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}} {{ $url := .Params.featureimage }}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }}
{{ $featured = resources.GetRemote $url }}
{{ if and .Params.featureimage (not $featured) }} {{ else }}
{{- $url:= .Params.featureimage -}} {{ $featured = resources.Get $url }}
{{ $featured = resources.GetRemote $url }} {{ end }}
{{ end }} {{ end }}
{{- if not $featured }} {{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultBackgroundImage }} {{ with .Site.Params.defaultBackgroundImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }} {{ $featured = resources.GetRemote . }}
@@ -18,7 +25,7 @@
{{ $featured = resources.Get . }} {{ $featured = resources.Get . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end -}} {{ end }}
{{ $isParentList := eq (.Scratch.Get "scope") "list" }} {{ $isParentList := eq (.Scratch.Get "scope") "list" }}
{{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or {{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or

View File

@@ -1,16 +1,23 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{- $images := .Resources.ByType "image" -}} {{ $featured := "" }}
{{- $featured := $images.GetMatch "*background*" -}} {{ if .Params.featureimage }}
{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}} {{ $url := .Params.featureimage }}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }}
{{ $featured = resources.GetRemote $url }}
{{ if and .Params.featureimage (not $featured) }} {{ else }}
{{- $url:= .Params.featureimage -}} {{ $featured = resources.Get $url }}
{{ $featured = resources.GetRemote $url }} {{ end }}
{{ end }} {{ end }}
{{- if not $featured }} {{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultBackgroundImage }} {{ with .Site.Params.defaultBackgroundImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }} {{ $featured = resources.GetRemote . }}
@@ -18,7 +25,7 @@
{{ $featured = resources.Get . }} {{ $featured = resources.Get . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end -}} {{ end }}
{{- with $featured -}} {{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}

View File

@@ -1,16 +1,23 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{- $images := .Resources.ByType "image" -}} {{ $featured := "" }}
{{- $featured := $images.GetMatch "*background*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if .Params.featureimage }} {{ if .Params.featureimage }}
{{- $url:= .Params.featureimage -}} {{ $url := .Params.featureimage }}
{{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} {{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }}
{{ $featured = resources.GetRemote $url }}
{{ else }}
{{ $featured = resources.Get $url }}
{{ end }}
{{ end }} {{ end }}
{{- if not $featured }} {{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultBackgroundImage }} {{ with .Site.Params.defaultBackgroundImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }} {{ $featured = resources.GetRemote . }}
@@ -18,7 +25,7 @@
{{ $featured = resources.Get . }} {{ $featured = resources.Get . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end -}} {{ end }}
{{ $caption := "" }} {{ $caption := "" }}
{{ if .Params.featureimagecaption }} {{ if .Params.featureimagecaption }}

View File

@@ -1,9 +1,9 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{- $images := .Resources.ByType "image" -}} {{ $images := .Resources.ByType "image" }}
{{- $background := $images.GetMatch "*background*" -}} {{ $background := $images.GetMatch "*background*" }}
{{- if not $background }} {{ if not $background }}
{{ with .Site.Params.defaultBackgroundImage }} {{ with .Site.Params.defaultBackgroundImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $background = resources.GetRemote . }} {{ $background = resources.GetRemote . }}
@@ -11,19 +11,30 @@
{{ $background = resources.Get . }} {{ $background = resources.Get . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end -}}
{{- if not $background }}{{ $background = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- if not $background }}{{ $background = $images.GetMatch "*feature*" }}{{ end -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if .Params.featureimage }}
{{- $url:= .Params.featureimage -}}
{{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}}
{{ end }} {{ end }}
{{- if not $featured }}{{ $featured = $images.GetMatch "*background*" }}{{ end -}}
{{- if not $featured }} {{ range slice "*cover*" "*thumbnail*" "*feature*" }}
{{ if not $background }}{{ $background = $images.GetMatch . }}{{ end }}
{{ end }}
{{ $featured := "" }}
{{ if .Params.featureimage }}
{{ $url := .Params.featureimage }}
{{ if or (strings.HasPrefix $url "http:") (strings.HasPrefix $url "https:") }}
{{ $featured = resources.GetRemote $url }}
{{ else }}
{{ $featured = resources.Get $url }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" "*background*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }} {{ with .Site.Params.defaultFeaturedImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }} {{ $featured = resources.GetRemote . }}
@@ -31,7 +42,7 @@
{{ $featured = resources.Get . }} {{ $featured = resources.Get . }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end -}} {{ end }}
{{ $isParentList := eq (.Scratch.Get "scope") "list" }} {{ $isParentList := eq (.Scratch.Get "scope") "list" }}
{{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or {{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or

View File

@@ -1,31 +1,21 @@
<a href="{{ .Page.RelPermalink }}" class="min-w-full"> <a href="{{ .Page.RelPermalink }}" class="min-w-full">
<div <div
class="border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative"> class="border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative">
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{- with site.Params.images -}} {{- $images := .Page.Resources.ByType "image" -}}
{{- range first 6 . }} {{- $featured := $images.GetMatch "*feature*" -}}
<meta property="og:image" content="{{ . | absURL }}"> {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ end -}} {{- with $featured -}}
{{- else -}} {{ if $disableImageOptimization }}
{{- $images := .Page.Resources.ByType "image" -}} {{ with . }}
{{- $featured := $images.GetMatch "*feature*" -}} <div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
{{ if $disableImageOptimization }}
{{ with . }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{ else }}
{{ with .Resize "600x" }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{ end }} {{ end }}
{{- else -}} {{ else }}
{{- with site.Params.images }} {{ with .Resize "600x" }}
<meta property="og:image" content="{{ index . 0 | absURL }}"> <div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div>
{{ end -}} {{ end }}
{{- end -}} {{ end }}
{{- end -}} {{- end -}}
{{ if site.Params.taxonomy.showTermCount | default true }} {{ if site.Params.taxonomy.showTermCount | default true }}