squirrel/layouts/partials/slider.html
2021-02-25 22:23:58 +01:00

38 lines
No EOL
1.4 KiB
HTML

{{- $slider := .Site.Params.slider }}
{{ $length := len $slider }}
{{ $template := resources.Get "scss/slider.scss" }}
{{ if $template }}
{{ $slider := $template | resources.ExecuteAsTemplate "css/slider.scss" . | resources.ToCSS (dict "outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $slider.Permalink }}">
{{ end }}
<!-- <link rel="stylesheet" type="text/css" href="/css/slider.css"> -->
<div class="slider">
{{ if gt $length 1}}
<div class=slide-links>
{{- range $index, $slide := $slider}}
<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}}
<div class="slide">
<img src="{{ $slide.image }}" alt="{{ $index }}">
{{ 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 }}