slider.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {{ $ := .root }}
  2. {{ $page := .page }}
  3. {{ $hash_id := .hash_id }}
  4. <!-- Indicators -->
  5. <ol class="carousel-indicators">
  6. {{ range $index, $item := $page.Params.item }}
  7. <li data-target="#{{$hash_id}}" data-slide-to="{{$index}}" {{if eq $index 0}}class="active"{{end}}></li>
  8. {{ end }}
  9. </ol>
  10. <!-- Carousel slides wrapper -->
  11. <div class="carousel-inner">
  12. {{ range $index, $item := $page.Params.item }}
  13. {{ $style_bg := "" }}
  14. {{with $page.Params.height}}
  15. {{ $style_bg = printf "%s height: %s;" $style_bg . }}
  16. {{end}}
  17. {{ if $item.overlay_color }}
  18. {{ $style_bg = printf "%s background-color: %s;" $style_bg ($item.overlay_color | default "transparent") }}
  19. {{ end }}
  20. {{ if $item.overlay_img }}
  21. {{ $bg_img := resources.Get (printf "media/%s" $item.overlay_img) }}
  22. {{ if $bg_img }}
  23. {{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg $bg_img.Permalink }}
  24. {{ else }}
  25. {{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $item.overlay_img }}
  26. {{ end }}
  27. {{ if $item.overlay_filter }}
  28. {{ $style_bg = printf "%sfilter: brightness(%s);" $style_bg (string $item.overlay_filter) }}
  29. {{ end }}
  30. {{ end }}
  31. <div class="wg-hero dark carousel-item{{if eq $index 0}} active{{end}}" style="{{$style_bg | safeCSS}}">
  32. <div class="container" style="text-align: {{$item.align | default "left"}};">
  33. <h1 class="hero-title">
  34. {{ with $item.title }}{{ . | markdownify | emojify }}{{ end }}
  35. </h1>
  36. {{ with $item.content }}
  37. <p class="hero-lead" style="{{if eq $item.align "center"}}margin: 0 auto 0 auto;{{else if eq $item.align "right"}}margin-left: auto; margin-right: 0{{end}}">
  38. {{ . | markdownify | emojify }}
  39. </p>
  40. {{ end }}
  41. {{ if $item.cta_url }}
  42. {{ $pack := or .cta_icon_pack "fas" }}
  43. {{ $pack_prefix := $pack }}
  44. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  45. {{ $pack_prefix = "fa" }}
  46. {{ end }}
  47. <p>
  48. <a href="{{ $item.cta_url }}" class="btn btn-light btn-lg">
  49. {{- with $item.cta_icon -}}<i class="{{ $pack }} {{ $pack_prefix }}-{{ . }}" style="padding-right: 10px;"></i>{{- end -}}
  50. {{- $item.cta_label | emojify | safeHTML -}}
  51. </a>
  52. </p>
  53. {{ end }}
  54. </div>
  55. </div>
  56. {{ end }}
  57. </div>
  58. <!-- Left and right controls -->
  59. <a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
  60. <span class="carousel-control-prev-icon"></span>
  61. <span class="sr-only">Previous</span>
  62. </a>
  63. <a class="carousel-control-next" href="#{{$hash_id}}" data-slide="next">
  64. <span class="carousel-control-next-icon"></span>
  65. <span class="sr-only">Next</span>
  66. </a>