squirrel/layouts/partials/slider.html

44 lines
1.5 KiB
HTML
Raw Normal View History

{{- $slider := .slider }}
2022-06-27 14:09:44 +00:00
{{- $color := .color }}
{{ $length := len $slider.images }}
2022-06-27 14:09:44 +00:00
{{- $id := "slider"}}
{{if $slider.id}}
{{- $id := $slider.id}}
{{else if .id}}
{{- $id := .id }}
{{end}}
2021-02-25 21:23:58 +00:00
{{ $template := resources.Get "scss/slider.scss" }}
2022-06-27 14:09:44 +00:00
{{ if $template }}
{{ $index := $template | resources.ExecuteAsTemplate "css/slider.scss" . | resources.ToCSS (dict "outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $index.RelPermalink }}">
{{ end }}
<div id="{{ $id }}" class="slider">
2021-02-25 21:23:58 +00:00
{{ if gt $length 1}}
<div class=slide-links>
{{- range $index, $slide := $slider.images}}
2021-02-25 21:23:58 +00:00
<a class="slide-link {{if eq $index 0}} slide-link-active {{end}}" onclick="scrollToSlide({{$index}})"></a>
{{ end }}
</div>
{{ end }}
<div class="slides">
{{- range $index, $slide := $slider.images}}
2021-02-25 21:23:58 +00:00
<div class="slide">
<img src="{{ $slide }}" alt="{{ $index }}">
2021-02-25 21:23:58 +00:00
{{ if gt $length 1}}
<span class="slider-navigation-right" onclick="scrollToNextSlideNr({{$index}})">
<i class="fas fa-angle-right"></i>
</span>
<span class="slider-navigation-left" onclick="scrollToPrevSlideNr({{$index}})">
<i class="fas fa-angle-left"></i>
</span>
{{ end }}
</div>
{{- end }}
</div>
</div>
<script src="/js/slider.js"></script>
{{ if gt $length 1}}
<script>
window.setInterval(scrollToNextSlide, 10000)
</script>
{{ end }}