widget_page.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{ partial "header.html" . }}
  2. {{ partial "navbar.html" . }}
  3. <!-- Flag for jQuery -->
  4. <span id="homepage" class="d-none"></span>
  5. {{/* Get widget page path */}}
  6. {{ $page := "" }}
  7. {{ if .IsHome }}
  8. {{ $page = "/home" }}
  9. {{ else }}
  10. {{ $page = .File.Path }}
  11. {{ end }}
  12. {{/* Load page sections */}}
  13. {{ $headless_bundle := .Site.GetPage $page }}
  14. {{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
  15. {{/* Begin widget styling */}}
  16. {{ $bg := $st.Params.design.background }}
  17. {{ $style := "" }}
  18. {{ if $bg.color }}
  19. {{ $style = printf "background-color: %s;" ($bg.color | default "transparent") }}
  20. {{ end }}
  21. {{ if and $bg.gradient_start $bg.gradient_end }}
  22. {{ $style = printf "%sbackground-image: linear-gradient(%s, %s);" $style $bg.gradient_start $bg.gradient_end }}
  23. {{ end }}
  24. {{ if $bg.image }}
  25. {{ $darken := "" }}
  26. {{ if $bg.image_darken }}
  27. {{ $darken = printf "linear-gradient(rgba(0, 0, 0, %s), rgba(0, 0, 0, %s))," (string $bg.image_darken) (string $bg.image_darken) }}
  28. {{ end }}
  29. {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
  30. {{ $style = printf "%sbackground-image: %s url('%s');" $style $darken (printf "img/%s" $bg.image | absURL) }}
  31. {{ end }}
  32. {{ with $st.Params.advanced.css_style }}
  33. {{ $style = print $style . }}
  34. {{ end }}
  35. {{ $params := dict "root" $ "page" $st }}
  36. {{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
  37. {{ $widget := or $st.Params.widget "blank" }}
  38. {{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
  39. {{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
  40. {{ $widget_path := printf "widgets/%s.html" $widget }}
  41. {{ if in (slice "slider") $widget }}
  42. {{ partial $widget_path $params }}
  43. {{ else }}
  44. <section id="{{ $hash_id }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $st.Params.advanced.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}>
  45. <div class="container">
  46. {{ partial $widget_path $params }}
  47. </div>
  48. </section>
  49. {{ end }}
  50. {{ end }}
  51. {{ partial "footer_container.html" . }}
  52. {{ partial "footer.html" . }}