layouts: use Hugo to process thumbnails

This commit is contained in:
liushuyu 2023-03-25 23:43:48 -06:00
parent e625f3336e
commit a94bfba031
No known key found for this signature in database
GPG key ID: 23D1CE4534419437
2 changed files with 6 additions and 5 deletions

View file

@ -3,8 +3,9 @@
{{ $rating := index .Site.Data.compatibility .Params.compatibility }} {{ $rating := index .Site.Data.compatibility .Params.compatibility }}
<section class="section content pt-sm"> <section class="section content pt-sm">
<div class="has-text-centered py-md"> <div class="has-text-centered py-md">
{{ if (fileExists (print "static/images/game/boxart/" .File.BaseFileName ".png")) }} {{ $boxart := resources.Get (printf "/images/game/boxart/%s.png" $gameId) }}
<img src="{{ .Site.BaseURL }}/images/game/boxart/{{ .File.BaseFileName }}.png" /> {{ if $boxart }} {{ $boxart_thumb := $boxart.Fill "328x300" }}
<img src="{{ $boxart_thumb.Permalink }}" />
{{ else }} {{ else }}
<img src="{{ .Site.BaseURL }}/images/boxart.png" /> <img src="{{ .Site.BaseURL }}/images/boxart.png" />
{{ end }} {{ end }}
@ -187,8 +188,6 @@
<div class="tile is-ancestor"> <div class="tile is-ancestor">
{{ $files := readDir (printf "/static/images/screenshots0/%s/" .File.BaseFileName) }} {{ $files := readDir (printf "/static/images/screenshots0/%s/" .File.BaseFileName) }}
{{ range $index, $element := $files }} {{ range $index, $element := $files }}
{{ $fileTitle := (index (split .Name "-") 1) }}
{{ $fileTitle := (index (split $fileTitle ".") 0) }}
<div class="tile is-parent"> <div class="tile is-parent">
<div class="tile is-child is-boxed"> <div class="tile is-child is-boxed">
<a href="/images/screenshots0/{{ $gameId }}/{{ .Name }}"> <a href="/images/screenshots0/{{ $gameId }}/{{ .Name }}">

View file

@ -13,7 +13,9 @@
<div class="tile is-parent"> <div class="tile is-parent">
<div class="tile is-child is-boxed"> <div class="tile is-child is-boxed">
<a href="/images/screenshots/{{ .Name }}" title="{{ $fileTitle }}"> <a href="/images/screenshots/{{ .Name }}" title="{{ $fileTitle }}">
<img src="/images/screenshots/thumbs/{{ .Name }}" alt="{{ $fileTitle }}"> {{ $screenshot := resources.Get (printf "/images/screenshots/%s" .Name) }}
{{ $thumb := $screenshot.Fit "640x360 jpg" }}
<img src="{{ $thumb.Permalink }}" alt="{{ $fileTitle }}">
</a> </a>
</div> </div>
</div> </div>