{{ $ref := .Get "ref" }} {{ $lang := .Get "lang" | default "en" }} {{ $color := .Get "color" }} {{ $class := .Get "class" }} {{ $icon := .Get "icon" }} {{ $text := .Get "text" }} {{ $showButton := .Get "showButton" | default "false" | partial "utilities/CastBool.html" }} {{ $.Scratch.Set "url" $ref }} {{ if or (hasPrefix $ref "http://") (hasPrefix $ref "https://") }} {{ $.Scratch.Set "url" $ref }} {{ warnf "Setting URL to external link: %s - Page: %s" $ref .Page.RelPermalink }} {{ else }} {{ with where .Site.Sites "Language.Lang" "eq" $lang }} {{ with index . 0 }} {{ with .GetPage $ref }} {{ $.Scratch.Set "url" .RelPermalink }} {{ if eq $text "" }} {{ $text = .Title }} {{ end }} {{ else }} {{ errorf "Page not found: %s" .Page.RelPermalink }} {{ end }} {{ else }} {{ errorf "Language not found: %s - Page: %s" $lang .Page.RelPermalink }} {{ end }} {{ else }} {{ errorf "Language not found: %s - Page: %s" $lang .Page.RelPermalink }} {{ end }} {{ end }} {{ if $showButton }} {{ partial "assets/button.html" (dict "title" $text "href" ($.Scratch.Get "url") "color" $color "icon" $icon "class" $class) }} {{ else }} {{ partial "assets/link.html" (dict "destination" ($.Scratch.Get "url") "page" .Page "text" $text "title" $text "class" $class ) }} {{ end }}