{{- define "main" }} {{ $homepage := .Site.GetPage "homepage" }} {{ $widgets := $homepage.Resources }} {{ range $widgets }} {{ if .Params.widget.handler }} {{ partial "widgets/load" . }} {{ else }} {{ errorf "Failed to find widget param in %q" .Path }} {{ end }} {{/* Deprecation warning(v1.0.0) starts */}} {{ else }} {{ warnf "Param 'hero' in params.toml is deprecated and will be removed in Eureka v1.0.0. See https://www.wangchucheng.com/en/docs/hugo-eureka/homepage-configuration/" }}
{{- $imgLeft := partial "utils/get-image" (dict "context" . "url" .Site.Params.hero.imgLeft)}} {{- with $imgLeft }}
{{- end }}
{{ .Site.Params.hero.slogan }}
{{- $imgRight := partial "utils/get-image" (dict "context" . "url" .Site.Params.hero.imgRight)}} {{- with $imgRight }}
{{- end }}
{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{- partial "components/masonry" $pages }}
{{/* Deprecation warning(v1.0.0) ends */}} {{ end }} {{- end }} {{ define "partials/widgets/load" }} {{ $widget := .Params.widget }} {{ $fullScreenWidgets := slice "vintage" }} {{/* background config */}} {{ $backgroundClass := "" }} {{ $backgroundStyle := "" }} {{ if $widget.background.image }} {{ $image := partial "utils/get-image.html" (dict "context" . "url" $widget.background.image) }} {{ $backgroundStyle = print $backgroundStyle "background-image: url(" $image ");" }} {{/* background size */}} {{ $size := $widget.background.size }} {{ $sizeOptions := dict "auto" "bg-auto" "cover" "bg-cover" "contain" "bg-contain" }} {{ if $size }} {{ $size = index $sizeOptions $size }} {{ if $size }} {{ $backgroundClass = print $backgroundClass " " $size }} {{ else }} {{/* TODO error */}} {{ end }} {{ end }} {{/* background position */}} {{ $position := $widget.background.position }} {{ $positionOptions := dict "center" "bg-center" "top" "bg-top" "right" "bg-right" "bottom" "bg-bottom" "left" "bg-left" }} {{ if $position }} {{ $position = index $positionOptions $position }} {{ if $position }} {{ $backgroundClass = print $backgroundClass " " $position }} {{ else }} {{/* TODO error */}} {{ end }} {{ end }} {{/* background position */}} {{ $attachment := $widget.background.attachment }} {{ $attachmentOptions := dict "fixed" "bg-fixed" "local" "bg-local" "scroll" "bg-scroll" }} {{ if $attachment }} {{ $attachment = index $attachmentOptions $attachment }} {{ if $attachment }} {{ $backgroundClass = print $backgroundClass " " $attachment }} {{ else }} {{/* TODO error */}} {{ end }} {{ end }} {{ else }} {{/* background color */}} {{ $color := $widget.background.color }} {{ $colorOptions := dict "primary" "bg-primary-bg" "secondary" "bg-secondary-bg" "tertiary" "bg-tertiary-bg" }} {{ if $color }} {{ $colorClass := index $colorOptions $color }} {{ if $colorClass }} {{ $backgroundClass = print $backgroundClass " " $colorClass }} {{ else }} {{ $backgroundStyle = print $backgroundStyle "background-color: " $color ";"}} {{ end }} {{ else }} {{ $colorClass := index $colorOptions "primary" }} {{ $backgroundClass = print $backgroundClass " " $colorClass }} {{ end }} {{ end }} {{/* widget config */}} {{ $widgetClass := "" }} {{ if not (in $fullScreenWidgets $widget.handler) }} {{/* widget width */}} {{ $width := $widget.width }} {{ $widthOptions := dict "sm" "lg:w-2/3" "md" "lg:w-3/4" "lg" "lg:w-4/5" "xl" "w-full" }} {{ if $width }} {{ $widthClass := index $widthOptions $width }} {{ if $widthClass }} {{ $widgetClass = print $widgetClass " " $widthClass }} {{ end }} {{ else }} {{ $widthClass := index $widthOptions "md" }} {{ $widgetClass = print $widgetClass " " $widthClass }} {{ end }} {{/* widget height */}} {{ $height := $widget.height }} {{ $heightOptions := dict "sm" "h-64" "md" "h-96" "lg" "h-128" "xl" "h-160" "screen" "h-(screen-16)" }} {{ if $height }} {{ $heightClass := index $heightOptions $height }} {{ if $heightClass }} {{ $widgetClass = print $widgetClass " " $heightClass }} {{ end }} {{ end }} {{ $widgetClass = print $widgetClass " mx-auto px-6 md:px-8 xl:px-12 py-12" }} {{ end }}
{{ partial "widgets/load-sidebar" . }}
{{ end }} {{ define "partials/widgets/load-sidebar" }} {{ $sidebar := .Params.widget.sidebar }} {{ if $sidebar.position }} {{ $scaleClass := "" }} {{/* widget width */}} {{ $scale := $sidebar.scale }} {{ $scaleOptions := dict "sm" "lg:w-1/5" "md" "lg:w-1/4" "lg" "lg:w-1/3" "xl" "lg:w-1/2" }} {{ if $scale }} {{ $scaleClass = index $scaleOptions $scale }} {{ else }} {{ $scaleClass = index $scaleOptions "md" }} {{ end }}

{{ .Params.Title }}

{{ partial (printf "widgets/%s" .Params.widget.handler) . }}
{{ else }} {{ partial (printf "widgets/%s" .Params.widget.handler) . }} {{ end }} {{ end }}