1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ .Title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family:
system-ui,
Segoe UI,
Roboto,
Apple SD Gothic Neo,
AppleGothic,
sans-serif;
max-width: 900px;
margin: 32px auto;
padding: 0 16px;
}
h1 {
margin-bottom: 12px;
}
ul {
line-height: 1.9;
padding-left: 1.1rem;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.meta {
color: #666;
margin-top: 4px;
}
video {
width: 100%;
height: auto;
margin: 12px 0;
}
img.preview {
width: 100%;
height: auto;
margin: 12px 0;
}
.badge {
font-size: 0.8rem;
border: 1px solid #ccc;
border-radius: 6px;
padding: 2px 6px;
margin-left: 6px;
}
</style>
</head>
<body>
<h1>{{ .Title }}</h1>
<!-- 섹션 소개 글 -->
<div class="content">{{ .Content }}</div>
<!-- 인라인 플레이어 -->
<div id="player" style="display: none">
<video id="video" controls preload="metadata"></video>
<img id="image" class="preview" alt="" style="display:none" />
<div id="meta" class="meta"></div>
</div>
<ul id="list">
<!-- 페이지 폴더명 -> 페이지 객체 매핑 준비 (예: 250922/index.md → 키: 250922) -->
{{ $pagesByFolder := dict }}
{{ range $p := .Pages }}
{{ $folder := path.Base (printf "%s" $p.File.Dir) }}
{{ $pagesByFolder = merge $pagesByFolder (dict $folder $p) }}
{{ end }}
<!-- 이미 인라인으로 붙인 페이지 폴더 추적 (Scratch 사용) -->
{{ $.Scratch.Set "usedFolders" (slice) }}
<!-- 1) 섹션 폴더 바로 아래 mp4/mov (섹션 리소스) -->
{{ $secVids := .Resources.Match "*.{mp4,mov}" }}
{{ range $v := $secVids }}
<li>
<a href="{{ $v.RelPermalink }}" data-name="{{ $v.Name }}" class="vid"
>{{ $v.Name }}</a
>
<span class="badge">video</span>
</li>
<!-- 동명 폴더 페이지가 있으면 비디오 바로 아래에 함께 표시 (예: 250922.mp4 → 250922/ 페이지) -->
{{ $base := replaceRE "\\.[^.]+$" "" $v.Name }}
{{ with (index $pagesByFolder $base) }}
<li>
{{ $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 }}
<a href="{{ $vid.RelPermalink }}" data-name="{{ or $p.Title $vid.Name }}" class="vid">
{{ with $p.Title }}{{ . }}{{ else }}{{ $vid.Name }}{{ end }}
</a>
<span class="badge">video</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else if $img }}
<a href="{{ $img.RelPermalink }}" data-name="{{ or $p.Title $img.Name }}" class="img">
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
</a>
<span class="badge">image</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else if $heic }}
<a href="{{ $heic.RelPermalink }}" data-name="{{ or $p.Title $heic.Name }}" class="heic">
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
</a>
<span class="badge">heic</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else }}
<a href="{{ $p.RelPermalink }}">{{ $p.Title }}</a>
<span class="badge">note</span>
{{ end }}
</li>
{{ $.Scratch.Add "usedFolders" (slice $base) }}
{{ end }}
{{ end }}
<!-- 1-3) 섹션 폴더 바로 아래 HEIC (다운로드/새 탭 열기 전용) -->
{{ $secHeic := .Resources.Match "*.{heic,HEIC}" }}
{{ range $h := $secHeic }}
<li>
<a href="{{ $h.RelPermalink }}" data-name="{{ $h.Name }}" class="heic"
>{{ $h.Name }}</a
>
<span class="badge">heic</span>
</li>
{{ end }}
<!-- 1-2) 섹션 폴더 바로 아래 이미지/GIF (섹션 리소스) -->
{{ $secImgs := .Resources.Match "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ range $i := $secImgs }}
<li>
<a href="{{ $i.RelPermalink }}" data-name="{{ $i.Name }}" class="img"
>{{ $i.Name }}</a
>
<span class="badge">image</span>
</li>
{{ end }}
<!-- 2) 자식 페이지들 (노트/동영상 페이지) -->
{{ range $p := .Pages.ByDate.Reverse }}
{{ $folder := path.Base (printf "%s" $p.File.Dir) }}
{{ if in ($.Scratch.Get "usedFolders") $folder }}{{ continue }}{{ end }}
{{ $vid := $p.Resources.GetMatch "*.{mp4,mov}" }}
{{ $img := $p.Resources.GetMatch "*.{jpg,jpeg,png,gif,webp,svg}" }}
{{ $heic := $p.Resources.GetMatch "*.{heic,HEIC}" }}
<li>
{{ if $vid }}
<a
href="{{ $vid.RelPermalink }}"
data-name="{{ or $p.Title $vid.Name }}"
class="vid"
>
{{ with $p.Title }}{{ . }}{{ else }}{{ $vid.Name }}{{ end }}
</a>
<span class="badge">video</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else if $img }}
<a
href="{{ $img.RelPermalink }}"
data-name="{{ or $p.Title $img.Name }}"
class="img"
>
{{ with $p.Title }}{{ . }}{{ else }}{{ $img.Name }}{{ end }}
</a>
<span class="badge">image</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else if $heic }}
<a
href="{{ $heic.RelPermalink }}"
data-name="{{ or $p.Title $heic.Name }}"
class="heic"
>
{{ with $p.Title }}{{ . }}{{ else }}{{ $heic.Name }}{{ end }}
</a>
<span class="badge">heic</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ else }}
<a href="{{ $p.RelPermalink }}">{{ $p.Title }}</a>
<span class="badge">note</span>
{{ end }}
</li>
{{ end }} {{ if and (eq (len $secVids) 0) (eq (len .Pages) 0) }}
<li>No items yet.</li>
{{ end }}
</ul>
<script>
document.addEventListener("DOMContentLoaded", () => {
const list = document.getElementById("list");
const wrap = document.getElementById("player");
const video = document.getElementById("video");
const image = document.getElementById("image");
const meta = document.getElementById("meta");
list.addEventListener("click", (e) => {
const vid = e.target.closest("a.vid");
const img = e.target.closest("a.img");
if (!vid && !img) return; // note는 링크로 이동
e.preventDefault(); // 미디어는 인라인 표시
wrap.style.display = "";
meta.textContent = (vid || img).dataset.name || (vid || img).textContent.trim();
if (vid) {
image.style.display = "none";
image.removeAttribute("src");
video.style.display = "";
video.src = vid.getAttribute("href");
video.play().catch(() => {});
} else if (img) {
video.pause();
video.removeAttribute("src");
video.style.display = "none";
image.style.display = "";
image.src = img.getAttribute("href");
}
wrap.scrollIntoView({ behavior: "smooth", block: "nearest" });
});
});
</script>
</body>
</html>
|