1
Fork 0

Use larger images for metadata

This commit is contained in:
Jake Howard 2022-01-03 14:56:53 +00:00
parent 73bea50756
commit 3a7561d4a5
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -2,12 +2,12 @@
{{ .Scratch.Set "image" .Params.image }} {{ .Scratch.Set "image" .Params.image }}
{{ if hasPrefix .Params.image "resource:" }} {{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }} {{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Fill "800x418").Permalink }} {{ .Scratch.Set "image" ($resource.Resize "800x").Permalink }}
{{ else if hasPrefix .Params.image "unsplash:" }} {{ else if hasPrefix .Params.image "unsplash:" }}
{{ $unsplash_id := replace .Params.image "unsplash:" "" }} {{ $unsplash_id := replace .Params.image "unsplash:" "" }}
{{ $query := querify "client_id" (getenv "UNSPLASH_ACCESS_KEY") }} {{ $query := querify "client_id" (getenv "UNSPLASH_ACCESS_KEY") }}
{{ $unsplash_data := (getJSON "https://api.unsplash.com/photos/" $unsplash_id "?" $query )}} {{ $unsplash_data := (getJSON "https://api.unsplash.com/photos/" $unsplash_id "?" $query )}}
{{ .Scratch.Set "image" $unsplash_data.urls.small }} {{ .Scratch.Set "image" $unsplash_data.urls.regular }}
{{ end }} {{ end }}
{{ end }} {{ end }}