From c49783585937bc005b561cdd072cc9f71472cfaf Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sun, 26 Mar 2023 02:47:43 -0600 Subject: [PATCH] layouts: use Hugo to process game icons and banners --- layouts/game/meta.html | 4 ++-- layouts/sitemap.xml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/layouts/game/meta.html b/layouts/game/meta.html index 96ae3e2..b80cde9 100644 --- a/layouts/game/meta.html +++ b/layouts/game/meta.html @@ -3,8 +3,8 @@ - - + {{- $fn := printf "/images/game/icons/%s.png" .File.BaseFileName -}}{{- $icon := resources.Get $fn -}} + {{ with $icon }}{{- $thumb := .Fill "48x48 jpg" | resources.Copy (printf "%s.jpg" $fn) -}}{{ end }} {{ range .Params.tags }} diff --git a/layouts/sitemap.xml b/layouts/sitemap.xml index e00db85..957dd81 100644 --- a/layouts/sitemap.xml +++ b/layouts/sitemap.xml @@ -6,13 +6,13 @@ {{ .Permalink }} - {{ if (eq .Section "entry") }} - - {{ .Site.BaseURL }}/images/banners/{{ .Params.Banner | default (print .File.BaseFileName ".png") }} + {{ if (eq .Section "entry") }}{{- $banner_fn := .Params.Banner | default (print .File.BaseFileName ".png") -}} + {{- $fn := printf "/images/banners/%s" $banner_fn -}}{{- $banner := resources.Get $fn -}} + {{ with $banner }}{{- $thumb := .Fit "824x306 jpg" | resources.Copy (printf "%s.jpg" $fn) -}}{{ $thumb.Permalink }}{{ end }} {{ else if (eq .Section "game") }} - - {{ .Site.BaseURL }}/images/game/icons/{{ .File.BaseFileName }}.png + {{- $fn := printf "/images/game/icons/%s.png" .File.BaseFileName -}}{{- $icon := resources.Get $fn -}} + {{ with $icon }}{{- $thumb := .Fill "48x48 jpg" | resources.Copy (printf "%s.jpg" $fn) -}}{{ $thumb.Permalink }}{{ end }} {{ end }}