widget_page.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {{ partial "header.html" . }}
  2. {{ partial "navbar.html" . }}
  3. <!-- Flag for jQuery -->
  4. <span id="homepage" class="d-none"></span>
  5. {{/* Get widget page */}}
  6. {{ $page := "" }}
  7. {{ if .IsHome }}
  8. {{ $page = "/home" }}
  9. {{ else }}
  10. {{ $page = .File.Path }}
  11. {{ end }}
  12. {{ $headless_bundle := site.GetPage $page }}
  13. {{/* Check homepage exists */}}
  14. {{ if not $headless_bundle }}
  15. {{ errorf "Homepage not found or duplicate homepages detected for a localization! Add the `home/` folder (especially `/home/index.md`) to each language's content folder. For example, your site should have a `content/home/` folder containing `index.md` and your homepage sections, or for multi-language sites, `content/en/home/` and `content/zh/home/` etc. Refer to the 'Build Your Homepage' and 'Language' documentation at https://sourcethemes.com/academic/docs/ and the example homepage at https://github.com/gcushen/hugo-academic/tree/master/exampleSite/content/home/index.md ." }}
  16. {{ end }}
  17. {{/* Load page sections */}}
  18. {{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
  19. {{/* Begin widget styling */}}
  20. {{ $bg := $st.Params.design.background }}
  21. {{ $style := "" }}
  22. {{ if $bg.color }}
  23. {{ $style = printf "background-color: %s;" ($bg.color | default "transparent") }}
  24. {{ end }}
  25. {{ if and $bg.gradient_start $bg.gradient_end }}
  26. {{ $style = printf "%sbackground-image: linear-gradient(%s, %s);" $style $bg.gradient_start $bg.gradient_end }}
  27. {{ end }}
  28. {{ if $bg.image }}
  29. {{ $darken := "" }}
  30. {{ if $bg.image_darken }}
  31. {{ $darken = printf "linear-gradient(rgba(0, 0, 0, %s), rgba(0, 0, 0, %s))," (string $bg.image_darken) (string $bg.image_darken) }}
  32. {{ end }}
  33. {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
  34. {{ $style = printf "%sbackground-image: %s url('%s');" $style $darken (printf "img/%s" $bg.image | absURL) }}
  35. {{ end }}
  36. {{ with $st.Params.design.spacing.padding }}
  37. {{ $style_pad := printf "padding: %s;" (delimit . " ") }}
  38. {{ $style = print $style $style_pad }}
  39. {{ end }}
  40. {{ with $st.Params.advanced.css_style }}
  41. {{ $style = print $style . }}
  42. {{ end }}
  43. {{ $params := dict "root" $ "page" $st }}
  44. {{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
  45. {{ $widget := or $st.Params.widget "blank" }}
  46. {{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
  47. {{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
  48. {{ $widget_path := printf "widgets/%s.html" $widget }}
  49. {{ if in (slice "slider") $widget }}
  50. {{ partial $widget_path $params }}
  51. {{ else }}
  52. <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}}>
  53. <div class="container">
  54. {{ partial $widget_path $params }}
  55. </div>
  56. </section>
  57. {{ end }}
  58. {{ end }}
  59. {{ partial "footer_container.html" . }}
  60. {{ partial "footer.html" . }}