widget_page.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.design.spacing.padding }}
  33. {{ $style_pad := printf "padding: %s;" (delimit . " ") }}
  34. {{ $style = print $style $style_pad }}
  35. {{ end }}
  36. {{ with $st.Params.advanced.css_style }}
  37. {{ $style = print $style . }}
  38. {{ end }}
  39. {{ $params := dict "root" $ "page" $st }}
  40. {{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
  41. {{ $widget := or $st.Params.widget "blank" }}
  42. {{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
  43. {{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
  44. {{ $widget_path := printf "widgets/%s.html" $widget }}
  45. {{ if in (slice "slider") $widget }}
  46. {{ partial $widget_path $params }}
  47. {{ else }}
  48. <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}}>
  49. <div class="container">
  50. {{ partial $widget_path $params }}
  51. </div>
  52. </section>
  53. {{ end }}
  54. {{ end }}
  55. {{ partial "footer_container.html" . }}
  56. {{ partial "footer.html" . }}