widget_page.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{ partial "header.html" . }}
  2. {{ partial "navbar.html" . }}
  3. <!-- Flag for jQuery -->
  4. <span id="homepage" style="display: none"></span>
  5. {{ if .IsHome }}
  6. {{ .Scratch.Set "section" "home" }}
  7. {{ else }}
  8. {{ .Scratch.Set "section" .Section }}
  9. {{ end }}
  10. {{ $section := .Scratch.Get "section" }}
  11. <!-- Widgets -->
  12. {{ range $index, $page := where (where .Data.Pages "Section" $section) ".Params.active" "!=" false }}
  13. {{/* Begin widget styling */}}
  14. {{ $bg := $page.Params.background }}
  15. {{ $style := "" }}
  16. {{ if $bg.color }}
  17. {{ $style = printf "background-color: %s;" ($bg.color | default "transparent") }}
  18. {{ end }}
  19. {{ if and $bg.gradient_start $bg.gradient_end }}
  20. {{ $style = printf "%sbackground-image: linear-gradient(%s, %s);" $style $bg.gradient_start $bg.gradient_end }}
  21. {{ end }}
  22. {{ if $bg.image }}
  23. {{ $darken := "" }}
  24. {{ if $bg.image_darken }}
  25. {{ $darken = printf "linear-gradient(rgba(0, 0, 0, %s), rgba(0, 0, 0, %s))," (string $bg.image_darken) (string $bg.image_darken) }}
  26. {{ end }}
  27. {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
  28. {{ $style = printf "%sbackground-image: %s url('%s');" $style $darken (printf "img/%s" $bg.image | absURL) }}
  29. {{ end }}
  30. {{ with $page.Params.css_custom }}
  31. {{ $style = print $style . }}
  32. {{ end }}
  33. {{ $params := dict "root" $ "page" $page }}
  34. {{ $widget := or $page.Params.widget "custom" }}
  35. {{ $widget_path := printf "widgets/%s.html" $widget }}
  36. {{ if in (slice "slider") $widget }}
  37. {{ partial $widget_path $params }}
  38. {{ else }}
  39. <section id="{{ $page.File.TranslationBaseName }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $page.Params.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}>
  40. <div class="container">
  41. {{ partial $widget_path $params }}
  42. </div>
  43. </section>
  44. {{ end }}
  45. {{ end }}
  46. <!-- Page Footer -->
  47. {{ partial "footer_container.html" . }}
  48. {{ partial "footer.html" . }}