2023-09-23 19:25:51 +01:00
|
|
|
{{- $context := . -}}
|
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" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $width := 0 -}}
|
|
|
|
{{- $height := 0 -}}
|
2023-09-24 15:30:17 +01:00
|
|
|
{{- $imageStyle := .Get "imageStyle" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
|
|
|
|
{{/* Image processing options */}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
|
|
|
{{- $options := .Get "options" | default "800x webp q80" -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- if and $image (not (urls.Parse $image).Scheme) -}}
|
|
|
|
{{/* Process images in assets */}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- with resources.Get $image -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $processed := "" -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- if eq $method "Resize" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $processed = (.Resize $options) -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- else if eq $method "Fit" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $processed = (.Fit $options) -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- else if eq $method "Fill" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $processed = (.Fill $options) -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- else if eq $method "Crop" -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $processed = (.Crop $options) -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize." -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- end -}}
|
2023-09-23 19:25:51 +01:00
|
|
|
{{- $width = $processed.Width -}}
|
|
|
|
{{- $height = $processed.Height -}}
|
|
|
|
{{- $image = $processed.RelPermalink -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{/* Otherwise, use relative link of the image */}}
|
2023-09-24 11:03:34 +01:00
|
|
|
{{- if hasPrefix $image "/" -}}
|
|
|
|
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
|
|
|
{{- end -}}
|
2023-09-18 19:04:48 -04:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2024-02-20 17:59:31 -05:00
|
|
|
{{ $linkClass := "hover:hx-border-gray-300 hx-bg-transparent hx-shadow-sm dark:hx-border-neutral-800 hover:hx-bg-slate-50 hover:hx-shadow-md dark:hover:hx-border-neutral-700 dark:hover:hx-bg-neutral-900" }}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- with $image -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
{{ $linkClass = "hover:hx-border-gray-300 hx-bg-gray-100 hx-shadow dark:hx-border-neutral-700 dark:hx-bg-neutral-800 dark:hx-text-gray-50 hover:hx-shadow-lg dark:hover:hx-border-neutral-500 dark:hover:hx-bg-neutral-700" }}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- 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-09-23 19:25:51 +01:00
|
|
|
|
2023-07-28 22:10:48 +01:00
|
|
|
<a
|
2024-02-20 17:59:31 -05:00
|
|
|
class="hextra-card hx-group hx-flex hx-flex-col hx-justify-start hx-overflow-hidden hx-rounded-lg hx-border hx-border-gray-200 hx-text-current hx-no-underline dark:hx-shadow-none hover:hx-shadow-gray-100 dark:hover:hx-shadow-none hx-shadow-gray-100 active:hx-shadow-sm active:hx-shadow-gray-200 hx-transition-all hx-duration-200 {{ $linkClass }}"
|
2023-10-27 05:13:24 +07:00
|
|
|
{{- if $link -}}
|
|
|
|
href="{{ $href }}" {{ with $external }}target="_blank" rel="noreferrer"{{ end -}}
|
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-23 19:25:51 +01:00
|
|
|
<img
|
|
|
|
alt="{{ $title }}"
|
|
|
|
loading="lazy"
|
|
|
|
decoding="async"
|
|
|
|
src="{{ $image | safeURL }}"
|
|
|
|
{{ with $width }}width="{{ . }}"{{ end }}
|
|
|
|
{{ with $height }}height="{{ . }}"{{ end }}
|
2023-09-24 15:30:17 +01:00
|
|
|
{{ with $imageStyle }}style="{{ . | safeCSS }}"{{ end }}
|
2023-09-23 19:25:51 +01:00
|
|
|
/>
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2024-02-20 17:59:31 -05:00
|
|
|
{{- $padding := "hx-p-4" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- with $subtitle -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
{{- $padding = "hx-pt-4 hx-px-4" -}}
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-10 09:54:30 -04:00
|
|
|
|
2024-02-20 17:59:31 -05:00
|
|
|
<span class="hx-flex hx-font-semibold hx-items-start hx-gap-2 {{ $padding }} hx-text-gray-700 hover:hx-text-gray-900 dark:hx-text-neutral-200 dark:hover:hx-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 -}}
|
2024-02-20 17:59:31 -05:00
|
|
|
<div class="hx-line-clamp-3 hx-text-sm hx-font-normal hx-text-gray-500 dark:hx-text-gray-400 hx-px-4 hx-mb-4 hx-mt-2">{{- $subtitle | markdownify -}}</div>
|
2023-08-20 21:31:51 +01:00
|
|
|
{{- end -}}
|
2023-07-28 22:10:48 +01:00
|
|
|
</a>
|
2023-11-10 18:45:42 -05:00
|
|
|
{{- /* Strip trailing newline. */ -}}
|