Erstes Commit
This commit is contained in:
44
hugo/content/comics/_content.gotmpl
Normal file
44
hugo/content/comics/_content.gotmpl
Normal file
@@ -0,0 +1,44 @@
|
||||
{{ $basePath := "content/comics" }}
|
||||
{{ range (os.ReadDir $basePath) }}
|
||||
{{ if .IsDir }}
|
||||
{{ $comicDir := .Name }}
|
||||
{{ $fullPath := printf "%s/%s" $basePath $comicDir }}
|
||||
{{ $indexContent := readFile (printf "%s/_index.md" $fullPath) }}
|
||||
{{ $comicData := transform.Unmarshal $indexContent }}
|
||||
{{ $images := slice }}
|
||||
{{ range (os.ReadDir $fullPath) }}
|
||||
{{ if findRE "\\.(jpg|jpeg|png|webp|gif)$" .Name }}
|
||||
{{ $images = $images | append .Name }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $images = sort $images }}
|
||||
{{ $imageCount := len $images }}
|
||||
{{ range $index, $image := $images }}
|
||||
{{ if gt $index 0 }}
|
||||
{{ $pageNum := math.Add $index 1 }}
|
||||
{{ $nextPage := "" }}
|
||||
{{ $lastPage := "" }}
|
||||
{{ if lt $pageNum $imageCount }}
|
||||
{{ $nextPage = printf "../%d/" (math.Add $pageNum 1) }}
|
||||
{{ $lastPage = printf "../%d/" $imageCount }}
|
||||
{{ end }}
|
||||
{{ $prevPage := "../" }}
|
||||
{{ if gt $pageNum 2 }}
|
||||
{{ $prevPage = printf "../%d/" $index }}
|
||||
{{ end }}
|
||||
{{ $page := dict
|
||||
"path" (printf "%s/%d" $comicDir $pageNum)
|
||||
"title" (printf "%s, Seite %d" $comicData.title $pageNum)
|
||||
"description" $comicData.description
|
||||
"params" (dict
|
||||
"image" $image
|
||||
"next" $nextPage
|
||||
"prev" $prevPage
|
||||
"last" $lastPage
|
||||
)
|
||||
}}
|
||||
{{ $.AddPage $page }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user