Skip to content

Commit

Permalink
Slider block: only show controls/indicators if >1 slides are defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrueffer committed May 21, 2023
1 parent 1b9f139 commit 9f0c2b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/wowchemy/layouts/partials/blocks/slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
{{ $page := .wcPage }}
{{ $block := .wcBlock }}
{{ $hash_id := .wcIdentifier }}
{{ $slide_count := len $block.content.slides }}

<!-- Indicators -->
{{ if gt $slide_count 1 }}
<ol class="carousel-indicators">
{{ range $index, $item := $block.content.slides }}
<li data-target="#{{$hash_id}}" data-slide-to="{{$index}}" {{if eq $index 0}}class="active"{{end}}></li>
{{ end }}
</ol>
{{ end }}

<!-- Carousel slides wrapper -->
<div class="carousel-inner">
Expand Down Expand Up @@ -81,6 +84,7 @@ <h1 class="hero-title ">
</div>

<!-- Left and right controls -->
{{ if gt $slide_count 1 }}
<a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
<span class="sr-only">Previous</span>
Expand All @@ -89,3 +93,4 @@ <h1 class="hero-title ">
<span class="carousel-control-next-icon"></span>
<span class="sr-only">Next</span>
</a>
{{ end }}
5 changes: 5 additions & 0 deletions modules/wowchemy/layouts/partials/blocks/v1/slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
{{ $page := .wcPage }}
{{ $block := .wcBlock }}
{{ $hash_id := .wcIdentifier }}
{{ $slide_count := len $block.Params.content.slides }}

<!-- Indicators -->
{{ if gt $slide_count 1 }}
<ol class="carousel-indicators">
{{ range $index, $item := $block.Params.content.slides }}
<li data-target="#{{$hash_id}}" data-slide-to="{{$index}}" {{if eq $index 0}}class="active"{{end}}></li>
{{ end }}
</ol>
{{ end }}

<!-- Carousel slides wrapper -->
<div class="carousel-inner">
Expand Down Expand Up @@ -75,6 +78,7 @@ <h1 class="hero-title">
</div>

<!-- Left and right controls -->
{{ if gt $slide_count 1 }}
<a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
<span class="sr-only">Previous</span>
Expand All @@ -83,3 +87,4 @@ <h1 class="hero-title">
<span class="carousel-control-next-icon"></span>
<span class="sr-only">Next</span>
</a>
{{ end }}

0 comments on commit 9f0c2b7

Please sign in to comment.