Skip to content

Fix: More on-screen slides in carousel #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions layouts/partials/video-section-related.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,27 @@

{{ $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="2000">
<div id="videoCarousel" class="carousel slide" data-bs-ride="carousel" data-bs-interval="4000">
<div class="carousel-indicators">
{{ range $index, $_ := $sortedVideos }}
<button type="button" data-bs-target="#videoCarousel" data-bs-slide-to="{{ $index }}" {{ if eq $index 0
}}class="active" aria-current="true" {{ end }} aria-label="Slide {{ add $index 1 }}">
{{ 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">
<div class="col-12 col-md-8 col-lg-6">
<!-- 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"
Expand All @@ -73,9 +76,39 @@ <h4 class="video-title text-white mb-0">{{ .page.Title }}</h4>
</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">
Expand All @@ -91,7 +124,6 @@ <h4 class="video-title text-white mb-0">{{ .page.Title }}</h4>
{{ end }}
</div>


<style>

</style>