slider.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. {{ $ := .root }}
  2. {{ $page := .page }}
  3. {{ $hash_id := .hash_id }}
  4. <!-- Indicators -->
  5. <ol class="carousel-indicators">
  6. {{ range $index, $item := $page.Params.content.slides }}
  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.content.slides }}
  13. {{ $style_bg := "" }}
  14. {{ $style_filter := "" }}
  15. {{with $page.Params.design.slide_height}}
  16. {{ $style_bg = printf "%s height: %s;" $style_bg . }}
  17. {{end}}
  18. {{ with $item.background.color }}
  19. {{ $style_bg = printf "%s background-color: %s;" $style_bg (. | default "transparent") }}
  20. {{ end }}
  21. {{ if $item.background.media }}
  22. {{ $bg_img := resources.Get (printf "media/%s" $item.background.media) }}
  23. {{ if $bg_img }}
  24. {{ $style_bg = printf "%sbackground-image: url('%s'); background-repeat: no-repeat; background-position: %s; background-size: cover; " $style_bg $bg_img.Permalink ($item.background.position | default "center") }}
  25. {{ else }}
  26. {{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $item.overlay_img }}
  27. {{ end }}
  28. {{ with $item.background.brightness }}
  29. {{ $style_filter = printf "%s-webkit-backdrop-filter: brightness(%s); backdrop-filter: brightness(%s);" $style_filter (string .) (string .) }}
  30. {{ end }}
  31. {{ end }}
  32. <div class="carousel-item{{if eq $index 0}} active{{end}} {{with $page.Params.design.is_fullscreen}}fullscreen{{end}}" style="{{$style_bg | safeCSS}}">
  33. <div class="position-absolute d-flex w-100 h-100 justify-content-center align-items-center" style="{{$style_filter | safeCSS}}">
  34. {{/* To prevent control overlap, margins are based on $carousel-control-* in bootstrap-variables.scss */}}
  35. <div class="wg-hero dark container" style="margin-left: 6rem; margin-right: 6rem; text-align: {{$item.align | default "left"}};">
  36. <h1 class="hero-title">
  37. {{ with $item.title }}{{ . | markdownify | emojify }}{{ end }}
  38. </h1>
  39. {{ with $item.content }}
  40. <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}}">
  41. {{ . | markdownify | emojify }}
  42. </p>
  43. {{ end }}
  44. {{ if $item.link.url }}
  45. {{ $pack := $item.link.icon_pack | default "fas" }}
  46. {{ $pack_prefix := $pack }}
  47. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  48. {{ $pack_prefix = "fa" }}
  49. {{ end }}
  50. <p>
  51. <a href="{{ $item.link.url }}" class="btn btn-light btn-lg mt-3">
  52. {{- with $item.link.icon -}}<i class="{{ $pack }} {{ $pack_prefix }}-{{ . }}" style="padding-right: 10px;"></i>{{- end -}}
  53. {{- $item.link.text | emojify | markdownify | safeHTML -}}
  54. </a>
  55. </p>
  56. {{ end }}
  57. </div>
  58. </div>
  59. </div>
  60. {{ end }}
  61. </div>
  62. <!-- Left and right controls -->
  63. <a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
  64. <span class="carousel-control-prev-icon"></span>
  65. <span class="sr-only">Previous</span>
  66. </a>
  67. <a class="carousel-control-next" href="#{{$hash_id}}" data-slide="next">
  68. <span class="carousel-control-next-icon"></span>
  69. <span class="sr-only">Next</span>
  70. </a>