{{ $error := false }} {{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "white" "black" "body" "body" "body-tertiary" -}} {{ $supportedFlags := slice "true" "false" -}} {{- $id := printf "navbar-collapse-%d" (add .Ordinal 1) -}} {{ with .Get "id" }} {{ $id = . }} {{ end }} {{ $path := .Get "path" | default "" }} {{ $page := .Site.GetPage $path }} {{ if not $page }} {{ errorf "Invalid or missing value for param 'path': %s" $path -}} {{ errorf " - Location: %s" .Position -}} {{ $error = true -}} {{ end }} {{ $menus := "main" -}} {{ with .Get "menus" }}{{ $menus = .}}{{ end -}} {{ $size := "md" -}} {{ with .Get "size" }}{{ $size = . }}{{ end -}} {{ $supportedSizes := slice "xs" "sm" "md" "lg" "xl" -}} {{ if not (in $supportedSizes $size) -}} {{ errorf "Invalid value for param 'size': %s" $size -}} {{ $error = true -}} {{ end -}} {{ $style := "light" -}} {{ with .Get "style" }}{{ $style = . }}{{ end -}} {{ $supportedStyles := slice "light" "dark" -}} {{ if not (in $supportedStyles $style) -}} {{ errorf "Invalid value for param 'style': %s" $style -}} {{ $error = true -}} {{ end -}} {{ $inverseStyle := "light" -}} {{ if eq $style "light" }}{{ $inverseStyle = "dark" }}{{ end -}} {{ $color := "" -}} {{ with .Get "color" }} {{ $color = . }} {{ if not (in $supportedColors $color) -}} {{ errorf "Invalid value for param 'color': %s" $color -}} {{ $error = true -}} {{ end -}} {{ end -}} {{ $searchParam := "true" -}} {{ with .Get "search" }}{{ $searchParam = . }}{{ end -}} {{ if not (in $supportedFlags $searchParam) -}} {{ errorf "Invalid value for param 'search': %s" .Position -}} {{ $error = true -}} {{ end -}} {{ $modeParam := "true" -}} {{ with .Get "mode" }}{{ $modeParam = . }}{{ end -}} {{ if not (in $supportedFlags $modeParam) -}} {{ errorf "Invalid value for param 'mode': %s" .Position -}} {{ $error = true -}} {{ end -}} {{ $logo := "" -}} {{ with .Get "logo" }}{{ $logo = . }}{{ end -}} {{ $title := "" -}} {{ with .Get "title" }}{{ $title = . }}{{ end -}} {{- $class := .Get "class" | default "" -}} {{ if not $error -}} {{- partial "assets/navbar.html" (dict "id" $id "page" $page "size" $size "style" $style "color" $color "search" $searchParam "mode" $modeParam "menus" $menus "logo" $logo "title" $title "class" $class ) -}} {{ end -}}