2023-08-26 15:01:06 +01:00
|
|
|
{{- $link := .Get "link" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- $title := .Get "title" -}}
|
|
|
|
{{- $icon := .Get "icon" -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- $subtitle := .Get "subtitle" -}}
|
|
|
|
{{- $image := .Get "image" -}}
|
|
|
|
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
|
|
|
{{- $options := .Get "options" | default "800x webp q80" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- $context := . -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
|
2023-09-18 19:04:48 -04:00
|
|
|
|
|
|
|
{{/*- Adding asset support for images here, so that Hugo can do its image processing magic. -*/}}
|
|
|
|
{{/* Unfortunately we cannot pass .Resize/.Fit/.Fill as variables, so we're left with chaining IFs */}}
|
|
|
|
|
|
|
|
{{- if not (urls.Parse $image).Scheme -}}
|
|
|
|
{{- with resources.Get $image -}}
|
|
|
|
{{- if eq $method "Resize" -}}
|
|
|
|
{{- $image = (.Resize $options).RelPermalink -}}
|
|
|
|
{{- else if eq $method "Fit" -}}
|
|
|
|
{{- $image = (.Fit $options).RelPermalink -}}
|
|
|
|
{{- else if eq $method "Fill" -}}
|
|
|
|
{{- $image = (.Fill $options).RelPermalink -}}
|
|
|
|
{{- else if eq $method "Crop" -}}
|
|
|
|
{{- $image = (.Crop $options).RelPermalink -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-08-20 21:31:51 +01:00
|
|
|
{{ $linkClass := "hover:border-gray-300 bg-transparent shadow-sm dark:border-neutral-800 hover:bg-slate-50 hover:shadow-md dark:hover:border-neutral-700 dark:hover:bg-neutral-900" }}
|
|
|
|
{{- with $image -}}
|
|
|
|
{{ $linkClass = "hover:border-gray-300 bg-gray-100 shadow dark:border-neutral-700 dark:bg-neutral-800 dark:text-gray-50 hover:shadow-lg dark:hover:border-neutral-500 dark:hover:bg-neutral-700" }}
|
|
|
|
{{- end -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
|
2023-08-26 15:01:06 +01:00
|
|
|
{{- $external := strings.HasPrefix $link "http" -}}
|
2023-09-13 05:40:00 -04:00
|
|
|
{{- $href := cond (strings.HasPrefix $link "/") ($link | relURL) $link -}}
|
2023-09-10 09:54:30 -04:00
|
|
|
|
2023-07-28 22:10:48 +01:00
|
|
|
<a
|
2023-08-20 21:31:51 +01:00
|
|
|
class="hextra-card group flex flex-col justify-start overflow-hidden rounded-lg border border-gray-200 text-current no-underline dark:shadow-none hover:shadow-gray-100 dark:hover:shadow-none shadow-gray-100 active:shadow-sm active:shadow-gray-200 transition-all duration-200 {{ $linkClass }}"
|
2023-09-13 05:40:00 -04:00
|
|
|
href="{{ $href }}"
|
2023-09-10 09:54:30 -04:00
|
|
|
{{- if $external }}
|
|
|
|
target="_blank" rel="noreferrer"
|
2023-08-26 15:01:06 +01:00
|
|
|
{{- end -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
>
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- with $image -}}
|
2023-09-10 09:54:30 -04:00
|
|
|
<img alt="{{ $title }}" loading="lazy" decoding="async" style="color: transparent;" src="{{ $image | safeURL }}" />
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-10 09:54:30 -04:00
|
|
|
{{- $padding := "p-4" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- with $subtitle -}}
|
2023-09-10 09:54:30 -04:00
|
|
|
{{- $padding = "pt-4 px-4" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-10 09:54:30 -04:00
|
|
|
|
2023-08-20 21:31:51 +01:00
|
|
|
<span class="flex font-semibold items-start gap-2 {{ $padding }} text-gray-700 hover:text-gray-900 dark:text-neutral-200 dark:hover:text-neutral-50">
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- with $icon }}{{ partial "utils/icon.html" (dict "name" $icon) -}}{{- end -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- $title -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
</span>
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- with $subtitle -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
<div class="line-clamp-3 text-sm font-normal text-gray-500 dark:text-gray-400 px-4 mb-4 mt-2">{{- $subtitle | markdownify -}}</div>
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
</a>
|