| 
									
										
										
										
											2025-08-15 03:09:58 +02:00
										 |  |  | {{- /* | 
					
						
							|  |  |  | A shortcode to create a card. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @param {string} link The link to the card. | 
					
						
							|  |  |  | @param {string} title The title of the card. | 
					
						
							|  |  |  | @param {string} icon The icon of the card. | 
					
						
							|  |  |  | @param {string} subtitle The subtitle of the card. | 
					
						
							|  |  |  | @param {string} tag The tag of the card. | 
					
						
							| 
									
										
										
										
											2025-08-23 15:42:23 +02:00
										 |  |  | @param {string} tagColor The color of the tag. | 
					
						
							| 
									
										
										
										
											2025-08-15 03:09:58 +02:00
										 |  |  | @param {string} image The image of the card. | 
					
						
							|  |  |  | @param {string} method The method to process the image. | 
					
						
							|  |  |  | @param {string} options The options to process the image. | 
					
						
							|  |  |  | @param {string} imageStyle The style of the image. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @example {{< card link="/" title="Image Card" }} | 
					
						
							|  |  |  | */ -}} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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" -}} | 
					
						
							| 
									
										
										
										
											2024-08-11 18:30:19 +02:00
										 |  |  | {{- $tag := .Get "tag" -}} | 
					
						
							| 
									
										
										
										
											2025-08-23 15:42:23 +02:00
										 |  |  | {{- $tagColor := .Get "tagColor" | default (.Get "tagType") | default "" -}}{{- /* Compatibility with previous parameter. */ -}} | 
					
						
							| 
									
										
										
										
											2025-08-25 17:49:06 +02:00
										 |  |  | {{- $tagBorder := not (eq (.Get "tagBorder") false) | default true }} | 
					
						
							|  |  |  | {{- $tagIcon := .Get "tagIcon" | default "" -}} | 
					
						
							| 
									
										
										
										
											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" -}} | 
					
						
							| 
									
										
										
										
											2025-01-06 06:00:00 +11:00
										 |  |  | {{- $process := .Get "process" | default (printf "%s %s" $method $options) -}} | 
					
						
							| 
									
										
										
										
											2023-07-28 22:10:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 18:05:13 +01:00
										 |  |  | {{- if and $image (not (urls.Parse $image).Scheme) -}} | 
					
						
							|  |  |  |   {{- with or (.Page.Resources.Get $image) (resources.Get $image) -}} | 
					
						
							|  |  |  |     {{/* .Process does not work on svgs */}} | 
					
						
							|  |  |  |     {{- if (not (eq .MediaType.SubType "svg")) -}} | 
					
						
							|  |  |  |       {{/* Retrieve the $image resource from local or global resources */}} | 
					
						
							|  |  |  |       {{- $processed := .Process $process -}} | 
					
						
							|  |  |  |       {{- $width = $processed.Width -}} | 
					
						
							|  |  |  |       {{- $height = $processed.Height -}} | 
					
						
							|  |  |  |       {{- $image = $processed.RelPermalink -}} | 
					
						
							|  |  |  |     {{- end -}} | 
					
						
							|  |  |  |   {{ else }} | 
					
						
							|  |  |  |     {{/* Otherwise, use relative link of the image */}} | 
					
						
							|  |  |  |     {{- if hasPrefix $image "/" -}} | 
					
						
							|  |  |  |       {{- $image = relURL (strings.TrimPrefix "/" $image) -}} | 
					
						
							|  |  |  |     {{- end -}} | 
					
						
							| 
									
										
										
										
											2023-09-18 19:04:48 -04:00
										 |  |  |   {{- end -}} | 
					
						
							|  |  |  | {{- end -}} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-31 12:06:47 +02:00
										 |  |  | {{- partial "shortcodes/card" (dict | 
					
						
							|  |  |  |   "page"        .Page | 
					
						
							|  |  |  |   "link"        $link | 
					
						
							|  |  |  |   "title"       $title | 
					
						
							|  |  |  |   "icon"        $icon | 
					
						
							|  |  |  |   "subtitle"    $subtitle | 
					
						
							|  |  |  |   "image"       $image | 
					
						
							|  |  |  |   "width"       $width | 
					
						
							|  |  |  |   "height"      $height | 
					
						
							|  |  |  |   "imageStyle"  $imageStyle | 
					
						
							| 
									
										
										
										
											2024-08-11 18:30:19 +02:00
										 |  |  |   "tag"         $tag | 
					
						
							| 
									
										
										
										
											2025-08-23 15:42:23 +02:00
										 |  |  |   "tagType"     $tagColor | 
					
						
							| 
									
										
										
										
											2025-08-25 17:49:06 +02:00
										 |  |  |   "tagBorder"   $tagBorder | 
					
						
							|  |  |  |   "tagIcon"     $tagIcon | 
					
						
							| 
									
										
										
										
											2024-03-31 12:06:47 +02:00
										 |  |  |   ) | 
					
						
							|  |  |  | -}} |