mirror of
				https://github.com/imfing/hextra.git
				synced 2025-11-04 03:24:52 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{{- $context := . -}}
 | 
						|
{{- $link := .Get "link" -}}
 | 
						|
{{- $title := .Get "title" -}}
 | 
						|
{{- $icon := .Get "icon" -}}
 | 
						|
{{- $subtitle := .Get "subtitle" -}}
 | 
						|
{{- $image := .Get "image" -}}
 | 
						|
{{- $width := 0 -}}
 | 
						|
{{- $height := 0 -}}
 | 
						|
{{- $imageStyle := .Get "imageStyle" -}}
 | 
						|
{{- $tag := .Get "tag" -}}
 | 
						|
{{- $tagType := .Get "tagType" -}}
 | 
						|
 | 
						|
{{/* Image processing options */}}
 | 
						|
{{- $method := .Get "method" | default "Resize" | humanize -}}
 | 
						|
{{- $options := .Get "options" | default "800x webp q80" -}}
 | 
						|
 | 
						|
{{- if and $image (not (urls.Parse $image).Scheme) -}}
 | 
						|
  {{/* Process images in assets */}}
 | 
						|
  {{- with resources.Get $image -}}
 | 
						|
    {{- $processed := "" -}}
 | 
						|
    {{- if eq $method "Resize" -}}
 | 
						|
      {{- $processed = (.Resize $options) -}}
 | 
						|
    {{- else if eq $method "Fit" -}}
 | 
						|
      {{- $processed = (.Fit $options) -}}
 | 
						|
    {{- else if eq $method "Fill" -}}
 | 
						|
      {{- $processed = (.Fill $options) -}}
 | 
						|
    {{- else if eq $method "Crop" -}}
 | 
						|
      {{- $processed = (.Crop $options) -}}
 | 
						|
    {{- else -}}
 | 
						|
      {{- errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize." -}}
 | 
						|
    {{- end -}}
 | 
						|
    {{- $width = $processed.Width -}}
 | 
						|
    {{- $height = $processed.Height -}}
 | 
						|
    {{- $image = $processed.RelPermalink -}}
 | 
						|
  {{- else -}}
 | 
						|
    {{/* Otherwise, use relative link of the image */}}
 | 
						|
    {{- if hasPrefix $image "/" -}}
 | 
						|
      {{- $image = relURL (strings.TrimPrefix "/" $image) -}}
 | 
						|
    {{- end -}}
 | 
						|
  {{- end -}}
 | 
						|
{{- end -}}
 | 
						|
 | 
						|
{{- partial "shortcodes/card" (dict
 | 
						|
  "page"        .Page
 | 
						|
  "link"        $link
 | 
						|
  "title"       $title
 | 
						|
  "icon"        $icon
 | 
						|
  "subtitle"    $subtitle
 | 
						|
  "image"       $image
 | 
						|
  "width"       $width
 | 
						|
  "height"      $height
 | 
						|
  "imageStyle"  $imageStyle
 | 
						|
  "tag"         $tag
 | 
						|
  "tagType"     $tagType
 | 
						|
  )
 | 
						|
-}}
 |