{{ $pagesByFolder := dict }}
{{ range $p := .Pages }}
{{ $folder := path.Base (printf "%s" $p.File.Dir) }}
{{ $pagesByFolder = merge $pagesByFolder (dict $folder $p) }}
{{ end }}
{{ $.Scratch.Set "usedFolders" (slice) }}
{{ $secVids := .Resources.Match "*.{mp4,mov}" }}
{{ range $v := $secVids }}
-
{{ $v.Name }}
video
{{ $base := replaceRE "\\.[^.]+$" "" $v.Name }}
{{ with (index $pagesByFolder $base) }}
-
{{ $p := . }}
{{ $vid := $p.Resources.GetMatch "*.{mp4,mov}" }}
{{ $img := $p.Resources.GetMatch "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ $heic := $p.Resources.GetMatch "*.{heic,HEIC}" }}
{{ if $vid }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $vid.Name }}{{ end }}
video
{{ $p.Date.Format "2006-01-02" }}
{{ else if $img }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
image
{{ $p.Date.Format "2006-01-02" }}
{{ else if $heic }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
heic
{{ $p.Date.Format "2006-01-02" }}
{{ else }}
{{ $p.Title }}
note
{{ end }}
{{ $.Scratch.Add "usedFolders" (slice $base) }}
{{ end }}
{{ end }}
{{ $secHeic := .Resources.Match "*.{heic,HEIC}" }}
{{ range $h := $secHeic }}
-
{{ $h.Name }}
heic
{{ end }}
{{ $secImgs := .Resources.Match "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ range $i := $secImgs }}
-
{{ $i.Name }}
image
{{ end }}
{{ $subfolderFiles := .Resources.Match "**/*.{mp4,mov,jpg,jpeg,png,gif,webp,svg,heic,HEIC}" }}
{{ $.Scratch.Set "folderGroups" (dict) }}
{{ range $f := $subfolderFiles }}
{{ $dir := path.Dir $f.RelPermalink }}
{{ if ne $dir "." }}
{{ $folderName := path.Base $dir }}
{{ $currentGroups := $.Scratch.Get "folderGroups" }}
{{ $folderFiles := index $currentGroups $folderName }}
{{ if $folderFiles }}
{{ $.Scratch.Add (printf "folder_%s" $folderName) (slice $f) }}
{{ else }}
{{ $.Scratch.Set (printf "folder_%s" $folderName) (slice $f) }}
{{ $newGroups := merge $currentGroups (dict $folderName true) }}
{{ $.Scratch.Set "folderGroups" $newGroups }}
{{ end }}
{{ end }}
{{ end }}
{{ $folderGroups := $.Scratch.Get "folderGroups" }}
{{ range $folderName, $exists := $folderGroups }}
{{ $files := $.Scratch.Get (printf "folder_%s" $folderName) }}
-
{{ range $f := $files }}
{{ $ext := path.Ext $f.Name | lower }}
-
{{ $f.Name }}
{{ if in (slice ".mp4" ".mov") $ext }}video{{ else if in (slice ".jpg" ".jpeg" ".png" ".gif" ".webp" ".svg") $ext }}image{{ else if in (slice ".heic") $ext }}heic{{ end }}
{{ end }}
{{ end }}
{{ range $p := .Pages.ByDate.Reverse }}
{{ $folder := path.Base (printf "%s" $p.File.Dir) }}
{{ if in ($.Scratch.Get "usedFolders") $folder }}{{ continue }}{{ end }}
{{ if eq $p.File.BaseFileName "whoareyou" }}{{ continue }}{{ end }}
{{ $vid := $p.Resources.GetMatch "*.{mp4,mov}" }}
{{ $img := $p.Resources.GetMatch "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ $heic := $p.Resources.GetMatch "*.{heic,HEIC}" }}
-
{{ if $vid }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $vid.Name }}{{ end }}
video
{{ $p.Date.Format "2006-01-02" }}
{{ else if $img }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
image
{{ $p.Date.Format "2006-01-02" }}
{{ else if $heic }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
heic
{{ $p.Date.Format "2006-01-02" }}
{{ else }}
{{ $p.Date.Format "2006-01-02" }} {{ $p.Title }}
note
{{ end }}
{{ end }}
{{ if and (eq (len $secVids) 0) (eq (len .Pages) 0) }}
- No items yet.
{{ end }}