generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathvideo-section-related.html
129 lines (116 loc) · 7.32 KB
/
video-section-related.html
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
<div class="section-index">
{{ $currentPage := .Page }}
{{ $currentTags := .Params.tags }}
{{ $currentCategories := .Params.categories }}
{{ $videoPages := (where .Site.Pages ".Params.video_id" "!=" nil) }}
{{ $matchingVideos := slice }}
{{ range $videoPages }}
{{ $page := . }}
{{ $matchScore := 0 }}
{{ range $currentTags }}
{{ if in $page.Params.tags . }}
{{ $matchScore = add $matchScore 1 }}
{{ end }}
{{ end }}
{{ range $currentCategories }}
{{ if in $page.Params.categories . }}
{{ $matchScore = add $matchScore 2 }}
{{ end }}
{{ end }}
{{ if gt $matchScore 0 }}
{{ $matchingVideos = $matchingVideos | append (dict "page" $page "score" $matchScore) }}
{{ end }}
{{ end }}
{{ $sortedVideos := sort $matchingVideos "score" "desc" }}
{{ if gt (len $sortedVideos) 0 }}
<div class="related-videos">
<h2>Related Videos</h2>
<div id="videoCarousel" class="carousel slide" data-bs-ride="carousel" data-bs-interval="4000">
<div class="carousel-indicators">
{{ range $index, $_ := $sortedVideos }}
{{ if modBool $index 2 }}
<button type="button" data-bs-target="#videoCarousel" data-bs-slide-to="{{ div $index 2 }}" {{ if eq $index 0
}}class="active" aria-current="true" {{ end }} aria-label="Slide {{ add (div $index 2) 1 }}">
</button>
{{ end }}
{{ end }}
</div>
<div class="carousel-inner">
{{ range $index, $video := $sortedVideos }}
{{ if modBool $index 2 }}
<div class="carousel-item {{ if eq $index 0 }}active{{ end }}">
<div class="row justify-content-center">
<!-- First video in pair -->
<div class="col-12 col-md-6 col-lg-5">
<a href="{{ .page.RelPermalink }}" class="video-link text-decoration-none">
<div class="video card h-100 bg-dark text-white border border-secondary shadow-lg p-1">
<div class="video-container position-relative"
style="height: max-content; overflow: hidden;">
<div class="ratio ratio-16x9 h-100">
<img src="https://i.ytimg.com/vi/{{ .page.Params.video_id }}/maxresdefault.jpg"
alt="{{ .page.Title }}" class="img-fluid" />
</div>
<div class="position-absolute top-0 start-0 w-100 h-100 bg-gradient-overlay">
<div
class="video-btn-wrapper position-absolute top-50 start-50 translate-middle">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 57 60">
<path class="play-icon-path"
d="M39.5298 29.028L21.7045 39.395C21.6471 39.4284 21.5893 39.4603 21.5311 39.4908C20.9134 39.8161 20.2107 40 19.4654 40C16.9992 40 15 37.9861 15 35.5018V14.5102C15 13.6377 15.2466 12.8233 15.6734 12.1337C16.9369 10.0722 19.6075 9.38388 21.7044 10.6034L39.5291 20.97C40.2869 21.3504 40.9459 21.9517 41.401 22.7457C41.811 23.4611 42.0038 24.2428 41.9999 25.0133C41.999 25.7747 41.806 26.5461 41.4009 27.2527C40.9461 28.0464 40.2873 28.6476 39.5298 29.028Z" />
</svg>
</div>
</div>
</div>
<div class="card-body">
<h4 class="video-title text-white mb-0">{{ .page.Title }}</h4>
</div>
</div>
</a>
</div>
{{ $nextIndex := add $index 1 }}
{{ if lt $nextIndex (len $sortedVideos) }}
{{ $nextVideo := index $sortedVideos $nextIndex }}
<div class="col-12 col-md-6 col-lg-5">
<a href="{{ $nextVideo.page.RelPermalink }}" class="video-link text-decoration-none">
<div class="video card h-100 bg-dark text-white border border-secondary shadow-lg p-1">
<div class="video-container position-relative"
style="height: max-content; overflow: hidden;">
<div class="ratio ratio-16x9 h-100">
<img src="https://i.ytimg.com/vi/{{ $nextVideo.page.Params.video_id }}/maxresdefault.jpg"
alt="{{ $nextVideo.page.Title }}" class="img-fluid" />
</div>
<div class="position-absolute top-0 start-0 w-100 h-100 bg-gradient-overlay">
<div
class="video-btn-wrapper position-absolute top-50 start-50 translate-middle">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 57 60">
<path class="play-icon-path"
d="M39.5298 29.028L21.7045 39.395C21.6471 39.4284 21.5893 39.4603 21.5311 39.4908C20.9134 39.8161 20.2107 40 19.4654 40C16.9992 40 15 37.9861 15 35.5018V14.5102C15 13.6377 15.2466 12.8233 15.6734 12.1337C16.9369 10.0722 19.6075 9.38388 21.7044 10.6034L39.5291 20.97C40.2869 21.3504 40.9459 21.9517 41.401 22.7457C41.811 23.4611 42.0038 24.2428 41.9999 25.0133C41.999 25.7747 41.806 26.5461 41.4009 27.2527C40.9461 28.0464 40.2873 28.6476 39.5298 29.028Z" />
</svg>
</div>
</div>
</div>
<div class="card-body">
<h4 class="video-title text-white mb-0">{{ $nextVideo.page.Title }}</h4>
</div>
</div>
</a>
</div>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#videoCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#videoCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
{{ end }}
</div>
<style>
</style>