layouts: use Hugo to process game icons and banners

This commit is contained in:
liushuyu 2023-03-26 02:47:43 -06:00
parent a94bfba031
commit c497835859
No known key found for this signature in database
GPG key ID: 23D1CE4534419437
2 changed files with 7 additions and 7 deletions

View file

@ -3,8 +3,8 @@
<meta property="og:description" content="{{ $rating.name }} - {{ $rating.description }}" />
<meta name="description" content="{{ $rating.name }} - {{ $rating.description }}" />
<meta property="og:type" content="article" />
<meta property="og:image" content="{{ .Site.BaseURL }}/images/game/icons/{{ .File.BaseFileName }}.png" />
<meta property="og:type" content="article" />{{- $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) -}}<meta property="og:image" content="{{ $thumb.Permalink }}" />{{ end }}
<meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />
{{ range .Params.tags }}
<meta property="og:article:tag" content="{{ . }}" />

View file

@ -6,13 +6,13 @@
<loc>{{ .Permalink }}</loc>
{{ if (eq .Section "entry") }}
<image:image>
<image:loc>{{ .Site.BaseURL }}/images/banners/{{ .Params.Banner | default (print .File.BaseFileName ".png") }}</image:loc>
{{ if (eq .Section "entry") }}{{- $banner_fn := .Params.Banner | default (print .File.BaseFileName ".png") -}}
<image:image>{{- $fn := printf "/images/banners/%s" $banner_fn -}}{{- $banner := resources.Get $fn -}}
{{ with $banner }}<image:loc>{{- $thumb := .Fit "824x306 jpg" | resources.Copy (printf "%s.jpg" $fn) -}}{{ $thumb.Permalink }}</image:loc>{{ end }}
</image:image>
{{ else if (eq .Section "game") }}
<image:image>
<image:loc>{{ .Site.BaseURL }}/images/game/icons/{{ .File.BaseFileName }}.png</image:loc>
<image:image>{{- $fn := printf "/images/game/icons/%s.png" .File.BaseFileName -}}{{- $icon := resources.Get $fn -}}
{{ with $icon }}<image:loc>{{- $thumb := .Fill "48x48 jpg" | resources.Copy (printf "%s.jpg" $fn) -}}{{ $thumb.Permalink }}</image:loc>{{ end }}
</image:image>
{{ end }}