blob: 27209dda10f8479cee605931b807ea91b5c15402 (
plain)
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
|
<!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;
}
.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>
<div id="meta" class="meta"></div>
</div>
<ul id="list">
<!-- 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>
{{ end }}
<!-- 2) 자식 페이지들 (노트/동영상 페이지) -->
{{ range $p := .Pages.ByDate.Reverse }} {{ $vid := $p.Resources.GetMatch
"*.{mp4,mov}" }}
<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 }}
<a href="{{ $p.RelPermalink }}">{{ $p.Title }}</a>
<span class="badge">note</span>
<div class="meta">{{ $p.Date.Format "2006-01-02" }}</div>
{{ 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 meta = document.getElementById("meta");
list.addEventListener("click", (e) => {
const a = e.target.closest("a.vid");
if (!a) return; // note는 링크로 이동
e.preventDefault(); // video는 인라인 재생
video.src = a.getAttribute("href");
video.play().catch(() => {});
wrap.style.display = "";
meta.textContent = a.dataset.name || a.textContent.trim();
wrap.scrollIntoView({ behavior: "smooth", block: "nearest" });
});
});
</script>
</body>
</html>
|