{{ .Content }}
{{/* 섹션 레벨 배경음악 (recordings/ 루트에 오디오 파일이 있는 경우) */}}
{{ $secAudio := .Resources.Match "*.{mp3,m4a,ogg,wav,opus,OPUS,OGG,WAV,MP3,M4A}" }}
{{ with (index $secAudio 0) }}
BGM ▷
{{ end }}
{{ $secVids := .Resources.Match "*.{mp4,mov}" }}
{{ range $v := $secVids }}
{{ $v.Name }}
video
{{ 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" }}
{{/* Leak 폴더가 없으면 강제로 추가 (파일이 없어도 표시) */}}
{{ $leakLower := "leak" }}
{{ $hasLeak := false }}
{{ range $folderName, $exists := $folderGroups }}
{{ if eq (lower $folderName) $leakLower }}
{{ $hasLeak = true }}
{{ end }}
{{ end }}
{{ if not $hasLeak }}
{{ $folderGroups = merge $folderGroups (dict "Leak" true) }}
{{ $.Scratch.Set "folderGroups" $folderGroups }}
{{ $.Scratch.Set "folder_Leak" (slice) }}
{{ end }}
{{ $folderGroups = $.Scratch.Get "folderGroups" }}
{{ range $folderName, $exists := $folderGroups }}
{{ $files := $.Scratch.Get (printf "folder_%s" $folderName) }}
{{ $isRestricted := or (eq $folderName "hidden") (eq (lower $folderName) "leak") }}
{{ 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 }}
{{ $nowMonth := now.Format "2006-01" }}
{{ $.Scratch.Set "monthKeys" (slice) }}
{{ $.Scratch.Set "monthSeen" (dict) }}
{{ range $p := .Pages.ByDate.Reverse }}
{{ if eq $p.File.BaseFileName "whoareyou" }}{{ continue }}{{ end }}
{{ $dstr := $p.Date.Format "2006-01-02" }}
{{ $m := cond (eq $dstr "0001-01-01") "etc" ($p.Date.Format "2006-01") }}
{{ $seen := $.Scratch.Get "monthSeen" }}
{{ if not (index $seen $m) }}
{{ $.Scratch.Set "monthSeen" (merge $seen (dict $m true)) }}
{{ $.Scratch.Add "monthKeys" (slice $m) }}
{{ end }}
{{ $key := printf "month_%s" $m }}
{{ if $.Scratch.Get $key }}
{{ $.Scratch.Add $key (slice $p) }}
{{ else }}
{{ $.Scratch.Set $key (slice $p) }}
{{ end }}
{{ end }}
{{ $monthKeys := $.Scratch.Get "monthKeys" }}
{{ range $m := $monthKeys }}
{{ $key := printf "month_%s" $m }}
{{ $pages := $.Scratch.Get $key }}
{{ if eq $m $nowMonth }}
{{ range $p := $pages }}
{{ $vid := $p.Resources.GetMatch "*.{mp4,mov}" }}
{{ $img := $p.Resources.GetMatch "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ $heic := $p.Resources.GetMatch "*.{heic,HEIC}" }}
{{ $folderBase := path.Base $p.File.Dir }}
{{ $dateKey := $p.Date.Format "2006-01-02" }}
{{ if $vid }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $vid.Name }}{{ end }}
video
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else if $img }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
image
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else if $heic }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
heic
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else }}
{{ $d := $p.Date.Format "2006-01-02" }}
{{ if ne $d "0001-01-01" }}{{ $d }} {{ end }}{{ $p.Title }}
note
{{ end }}
{{ end }}
{{ else }}
{{ range $p := $pages }}
{{ $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
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else if $img }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
image
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else if $heic }}
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
heic
{{ $d := $p.Date.Format "2006-01-02" }}{{ if ne $d "0001-01-01" }}{{ $d }}
{{ end }}
{{ else }}
{{ $d := $p.Date.Format "2006-01-02" }}
{{ if ne $d "0001-01-01" }}{{ $d }} {{ end }}{{ $p.Title }}
note
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ if and (eq (len $secVids) 0) (eq (len .Pages) 0) }}
No items yet.
{{ end }}