Comics #838, #839
[nose_ears_website.git] / layouts / shortcodes / comicfilesize.html
blob030a72db97af2d0b17ac82986dcc101b7eea8e24
1 {{/* Returns the file size of all comic files combined in MiB, including the file size unit */}}
2 {{ $.Scratch.Set "total_size" 0 }}
3 {{ range (where (where .Site.AllPages "Section" "comic") "IsPage" true) -}}
4 {{ $comic_id := .File.ContentBaseName -}}
5 {{ $comicFilePath := delimit (slice "assets/comics/NE_" .Site.Language.Lang "_" $comic_id ".png") "" -}}
6 {{ $fileStat := os.Stat $comicFilePath }}
7 {{ $size := $fileStat.Size }}
8 {{ $.Scratch.Add "total_size" $size }}
9 {{ end -}}
10 {{ $total_size := $.Scratch.Get "total_size" }}
11 {{ $total_size_div := div (float $total_size) (float 1048576) }}
12 {{ printf "%.0f MiB" $total_size_div -}}