summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/list.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
new file mode 100644
index 0000000..52db7eb
--- /dev/null
+++ b/layouts/_default/list.html
@@ -0,0 +1,81 @@
1{{ define "main" }}
2<script>
3 document.addEventListener("DOMContentLoaded", () => {
4 for (const e of document.getElementsByClassName("js-only")) {
5 e.classList.remove("js-only");
6 }
7
8 const songs = document.querySelectorAll("li");
9 const search = document.getElementById("search");
10 const songlist = document.getElementById("song-list");
11
12 const normalize = str => str.normalize('NFD').replace(/\p{Diacritic}/gu, "");
13
14 search.addEventListener("input", () => {
15 const searchText = search.value.toLowerCase().trim();
16 const searchTerms = normalize(searchText).split(" ");
17 const hasFilter = searchText.length > 0;
18 songlist.classList.toggle("list-searched", hasFilter);
19
20 songs.forEach(song => {
21 const songText = normalize(`${song.textContent} ${song.dataset.alias}`).toLowerCase();
22 const isMatch = searchTerms.every(term => songText.includes(term));
23 song.hidden = !isMatch;
24 });
25 });
26
27 const clearSearch = document.getElementById("clear-search");
28 clearSearch.addEventListener("click", () => {
29 search.value = "";
30 songs.forEach(song => {
31 song.hidden = false;
32 });
33 songlist.classList.remove("list-searched");
34 });
35 });
36</script>
37
38<div class="list-container">
39
40
41 {{ $tagsPage := eq .Title "Tags"}}
42
43 <h2 class="center">What do you want to sing?</h2>
44 <div class="search-bar-container">
45 <div class="search-wrapper">
46 <input type="text" id="search" class="search-bar" placeholder="Search ALL Songs...">
47 <button id="clear-search" class="js-only">
48 <svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
49 <title>Backspace</title>
50 <path
51 d="M135.19 390.14a28.79 28.79 0 0021.68 9.86h246.26A29 29 0 00432 371.13V140.87A29 29 0 00403.13 112H156.87a28.84 28.84 0 00-21.67 9.84v0L46.33 256l88.86 134.11z"
52 fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path>
53 <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"
54 d="M336.67 192.33L206.66 322.34M336.67 322.34L206.66 192.33M336.67 192.33L206.66 322.34M336.67 322.34L206.66 192.33">
55 </path>
56 </svg></button>
57 </div>
58 </div>
59
60 <ul id="song-list">
61 {{ range .Pages }}
62 <li data-alias={{ if .Params.alias }}{{ .Params.alias }}{{ else }}{{ .Params.title }}{{ end }}>
63 <a href="{{ .RelPermalink }}">
64 {{ .Title }}
65 </a>
66 </li>
67 {{ end }}
68 </ul>
69</div>
70
71<div class="about">
72 {{ .Content }}
73</div>
74
75<div class="back-to-top">
76<a href="#top">
77 back to top
78</a>
79</div>
80
81{{ end }} \ No newline at end of file