Merge pull request #2252 from servedsmart/replace-custom-javascript-logic-with-anchor-tags

🚸 UX: Use anchor tags in article-meta/basic.html
This commit is contained in:
Nuno C.
2025-07-17 16:37:13 +01:00
committed by GitHub
4 changed files with 155 additions and 178 deletions
+58 -66
View File
@@ -1,78 +1,70 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ with .Params.externalUrl }} <div
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full"> class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
{{ else }} <a
<a href="{{ .RelPermalink }}" class="min-w-full"> {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
{{ end }} class="absolute inset-0"
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative"> aria-label="{{ $.Title }}"></a>
{{- with $.Params.images -}}
{{- with $.Params.images -}} {{- range first 6 . }}
{{- range first 6 . }} <meta property="og:image" content="{{ . | absURL }}">
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} {{ end -}}
{{- else -}} {{- else -}}
{{- $images := $.Resources.ByType "image" -}} {{- $images := $.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}} {{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if and .Params.featureimage (not $featured) }} {{ if and .Params.featureimage (not $featured) }}
{{- $url:= .Params.featureimage -}} {{- $url:= .Params.featureimage -}}
{{ $featured = resources.GetRemote $url }} {{ $featured = resources.GetRemote $url }}
{{ end }} {{ end }}
{{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{- if not $featured }}
{{- with $featured -}} {{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ end -}}
{{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
{{ with . }} {{ with . }}
<div class="w-full thumbnail_card_related nozoom" style="background-image:url({{ .RelPermalink }});"></div> <div
class="thumbnail_card_related nozoom w-full"
style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ with .Resize "600x" }} {{ with .Resize "600x" }}
<div class="w-full thumbnail_card_related nozoom" style="background-image:url({{ .RelPermalink }});"></div> <div
class="thumbnail_card_related nozoom w-full"
style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- else -}} {{- else -}}
{{- with $.Site.Params.images }} {{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}" />{{ end -}} <meta property="og:image" content="{{ index . 0 | absURL }}">
{{- end -}} {{ end -}}
{{- 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">
{{ with .Params.externalUrl }}
<div
<div class="px-6 py-4"> class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
{{ with .Params.externalUrl }} {{ $.Title | emojify }}
<div> <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
<div <span class="rtl:hidden">&#8599;</span>
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> <span class="ltr:hidden">&#8598;</span>
{{ $.Title | emojify }} </span>
<span class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500">
<span class="rtl:hidden">&#8599;</span>
<span class="ltr:hidden">&#8598;</span>
</span>
</div>
</div>
{{ else }}
<div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
href="{{ .RelPermalink }}">
{{ .Title | emojify }}
</div>
{{ end }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div> </div>
{{ else }}
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} <div
<div class="py-1 prose dark:prose-invert"> class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
{{ .Summary | plainify }} {{ .Title | emojify }}
</div> </div>
{{ end }} {{ end }}
</div> <div class="text-sm text-neutral-500 dark:text-neutral-400">{{ partial "article-meta/basic.html" . }}</div>
<div class="px-6 pt-4 pb-2"></div> {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="prose dark:prose-invert py-1">{{ .Summary | plainify }}</div>
{{ end }}
</div> </div>
</a> <div class="px-6 pt-4 pb-2"></div>
</div>
+55 -66
View File
@@ -1,78 +1,67 @@
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ with .Params.externalUrl }} <div
<a href="{{ . }}" target="_blank" rel="external" class="min-w-full"> class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
{{ else }} <a
<a href="{{ .RelPermalink }}" class="min-w-full"> {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
{{ end }} class="absolute inset-0"
<div class="min-h-full border border-neutral-200 dark:border-neutral-700 border-2 rounded overflow-hidden shadow-2xl relative"> aria-label="{{ $.Title }}"></a>
{{- with $.Params.images -}}
{{- with $.Params.images -}} {{- range first 6 . }}
{{- range first 6 . }} <meta property="og:image" content="{{ . | absURL }}">
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} {{ end -}}
{{- else -}} {{- else -}}
{{- $images := $.Resources.ByType "image" -}} {{- $images := $.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}} {{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if and .Params.featureimage (not $featured) }} {{ if and .Params.featureimage (not $featured) }}
{{- $url:= .Params.featureimage -}} {{- $url:= .Params.featureimage -}}
{{ $featured = resources.GetRemote $url }} {{ $featured = resources.GetRemote $url }}
{{ end }} {{ end }}
{{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{- if not $featured }}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{- with $featured -}} {{ end -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
{{ with . }} {{ with . }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div> <div class="thumbnail_card nozoom w-full" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ with .Resize "600x" }} {{ with .Resize "600x" }}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ .RelPermalink }});"></div> <div class="thumbnail_card nozoom w-full" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- else -}} {{- else -}}
{{- with $.Site.Params.images }} {{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}" />{{ end -}} <meta property="og:image" content="{{ index . 0 | absURL }}">
{{- end -}} {{ end -}}
{{- 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">
{{ with .Params.externalUrl }}
<div class="px-6 py-4"> <div
{{ with .Params.externalUrl }} class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
<div> {{ $.Title | emojify }}
<div <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> <span class="rtl:hidden">&#8599;</span>
{{ $.Title | emojify }} <span class="ltr:hidden">&#8598;</span>
<span class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500"> </span>
<span class="rtl:hidden">&#8599;</span>
<span class="ltr:hidden">&#8598;</span>
</span>
</div>
</div>
{{ else }}
<div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
href="{{ .RelPermalink }}">
{{ .Title | emojify }}
</div>
{{ end }}
<div class="text-sm text-neutral-500 dark:text-neutral-400">
{{ partial "article-meta/basic.html" . }}
</div> </div>
{{ else }}
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} <div
<div class="py-1 prose dark:prose-invert"> class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
{{ .Summary | plainify }} {{ .Title | emojify }}
</div> </div>
{{ end }} {{ end }}
</div> <div class="text-sm text-neutral-500 dark:text-neutral-400">{{ partial "article-meta/basic.html" . }}</div>
<div class="px-6 pt-4 pb-2"></div> {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="prose dark:prose-invert py-1">{{ .Summary | plainify }}</div>
{{ end }}
</div> </div>
</a> <div class="px-6 pt-4 pb-2"></div>
</div>
+35 -35
View File
@@ -1,6 +1,6 @@
{{ $constrainItemsWidth := .Page.Site.Params.list.constrainItemsWidth | default false }} {{ $constrainItemsWidth := .Page.Site.Params.list.constrainItemsWidth | default false }}
{{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }} {{ $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 }}
@@ -28,73 +28,73 @@
{{ end }} {{ end }}
<a class="{{ $articleClasses }}" {{ partial "article-link/_external-link.html" . | safeHTMLAttr }}> <div class="{{ $articleClasses }}">
<a
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
class="absolute inset-0"
aria-label="{{ $.Title }}"></a>
{{- with $.Params.images -}} {{- with $.Params.images -}}
{{- range first 6 . }} {{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />{{ end -}} <meta property="og:image" content="{{ . | absURL }}">
{{- else -}} {{ end -}}
{{- else -}}
{{- $images := $.Resources.ByType "image" -}} {{- $images := $.Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}} {{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{ if and .Params.featureimage (not $featured) }} {{ if and .Params.featureimage (not $featured) }}
{{- $url:= .Params.featureimage -}} {{- $url:= .Params.featureimage -}}
{{ $featured = resources.GetRemote $url }} {{ $featured = resources.GetRemote $url }}
{{ end }} {{ end }}
{{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} {{- if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end -}}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{- with $featured -}} {{- with $featured -}}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
{{ with . }} {{ with . }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> <div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ with .Resize "600x" }} {{ with .Resize "600x" }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div> <div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- else -}} {{- else -}}
{{- with $.Site.Params.images }} {{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}" />{{ end -}} <meta property="og:image" content="{{ index . 0 | absURL }}">
{{- end -}} {{ end -}}
{{- end -}} {{- end -}}
{{- end -}}
<div class="{{ $articleInnerClasses }}"> <div class="{{ $articleInnerClasses }}">
<div class="items-center text-left text-xl font-semibold"> <div class="items-center text-left text-xl font-semibold">
{{ with .Params.externalUrl }} {{ with .Params.externalUrl }}
<div> <div
<div class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"> {{ $.Title | emojify }}
{{ $.Title | emojify }} <span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
<span class="text-xs align-top cursor-default 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>
</div> </div>
{{ else }} {{ else }}
<div <div
class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral" class="decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
href="{{ .RelPermalink }}">
{{ .Title | emojify }} {{ .Title | emojify }}
</div> </div>
{{ end }} {{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<div class=" ltr:ml-2 rtl:mr-2"> <div class="ltr:ml-2 rtl:mr-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</div>
{{ 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> </div>
<div class="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" . }}</div>
{{ partial "article-meta/basic.html" . }}
</div>
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }} {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
<div class="py-1 max-w-fit prose dark:prose-invert"> <div class="prose dark:prose-invert max-w-fit py-1">{{ .Summary | plainify }}</div>
{{ .Summary | plainify }}
</div>
{{ end }} {{ end }}
</div> </div>
</a> <div class="px-6 pt-4 pb-2"></div>
</div>
+7 -11
View File
@@ -82,9 +82,7 @@
{{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }}
{{ range $i, $a := $context.GetTerms $taxonomy }} {{ range $i, $a := $context.GetTerms $taxonomy }}
{{ if not (eq $i 0) }},&nbsp;{{ end }} {{ if not (eq $i 0) }},&nbsp;{{ end }}
<div class="cursor-pointer" onclick="window.open({{ $a.RelPermalink }},'_self');return false;"> <a href="{{ $a.RelPermalink }}" class="relative">{{ $a.LinkTitle }}</a>
{{ $a.LinkTitle }}
</div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
@@ -99,11 +97,9 @@
{{ if and (not (eq $taxonomy "authors")) (not (eq $taxonomy "series")) }} {{ if and (not (eq $taxonomy "authors")) (not (eq $taxonomy "series")) }}
{{ if (gt (len ($context.GetTerms $taxonomy)) 0) }} {{ if (gt (len ($context.GetTerms $taxonomy)) 0) }}
{{ range $context.GetTerms $taxonomy }} {{ range $context.GetTerms $taxonomy }}
<span <a class="relative mt-[0.5rem] mr-2" href="{{ .RelPermalink }}"
class="mr-2 mt-[0.5rem]" >{{ partial "badge.html" .LinkTitle }}</a
onclick="window.open({{ .RelPermalink }},'_self');return false;"> >
{{ partial "badge.html" .LinkTitle }}
</span>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
@@ -115,9 +111,9 @@
{{ if .Params.showCategoryOnly | default (.Site.Params.article.showCategoryOnly | default false) }} {{ if .Params.showCategoryOnly | default (.Site.Params.article.showCategoryOnly | default false) }}
<div class="flex flex-row flex-wrap items-center"> <div class="flex flex-row flex-wrap items-center">
{{ range (.GetTerms "categories") }} {{ range (.GetTerms "categories") }}
<span class="mr-2 mt-[0.5rem]" onclick="window.open({{ .RelPermalink }},'_self');return false;"> <a class="relative mt-[0.5rem] mr-2" href="{{ .RelPermalink }}"
{{ partial "badge.html" .LinkTitle }} >{{ partial "badge.html" .LinkTitle }}</a
</span> >
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}