Skip to content

Commit

Permalink
feat: add the page-thumbnail function
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jul 3, 2023
1 parent 40e720d commit 44a4001
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- $images := partialCached "images/functions/page-image-resources" . . }}
{{- return $images.GetMatch "feature*" -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- return .Resources.ByType "image" -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- $img := partialCached "images/functions/page-featured-image-resource" . . }}
{{- if not $img }}
{{- $images := partialCached "images/functions/page-image-resources" . . }}
{{- $img = $images.GetMatch "{*cover*,*thumbnail*}" -}}
{{- end }}
{{- return $img -}}
20 changes: 20 additions & 0 deletions layouts/partials/images/functions/page-thumbnail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- $img := "" }}
{{- $page := .Page }}
{{- with $page.Params.images }}
{{- $img = index . 0 }}
{{- else }}
{{- $thumbnail := partialCached "images/functions/page-thumbnail-resource" $page $page }}
{{- with $thumbnail }}
{{- $img = replace .RelPermalink $page.RelPermalink "" | printf "%s?height=360px" }}
{{- end }}
{{- end }}
{{- $html := "" }}
{{- with $img }}
{{- $html = partial "images/image" (dict
"Filename" $img
"Page" $page
"Style" $.Style
"ClassName" $.ClassName)
}}
{{- end }}
{{- return $html }}

0 comments on commit 44a4001

Please sign in to comment.