diff --git a/exampleSite/assets/img/dark-logo.svg b/exampleSite/assets/img/dark-logo.svg new file mode 100644 index 00000000..321bef97 --- /dev/null +++ b/exampleSite/assets/img/dark-logo.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 3038930a..f85356e3 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -20,8 +20,8 @@ fingerprintAlgorithm = "sha256" [header] layout = "basic" # valid options: basic, hamburger, hybrid, custom - # logo = "img/logo.jpg" - # logoDark = "img/dark-logo.jpg" + logo = "img/logo.jpg" + logoDark = "img/dark-logo.svg" showTitle = true [footer] diff --git a/layouts/partials/logo.html b/layouts/partials/logo.html index ee119168..0e03203b 100644 --- a/layouts/partials/logo.html +++ b/layouts/partials/logo.html @@ -1,32 +1,30 @@ -{{- if .Site.Params.header.logo }} - {{- $logo := resources.Get .Site.Params.header.logo }} - {{- $logo_dark := resources.Get .Site.Params.header.logoDark }} - {{- if $logo }} - - - {{- if $logo_dark }} - {{ .Site.Title }} - {{- end}} +{{- if $.Page.Site.Params.header.logo }} + {{- $logo := resources.Get $.Page.Site.Params.header.logo }} + {{- $logo_dark := resources.Get $.Page.Site.Params.header.logoDark }} + {{- $logoAlt := $.Page.Site.Title -}} + {{- $logoClass := "max-h-[10rem] max-w-[10rem] object-scale-down object-left flex" -}} + {{- $logoDarkClass := (print $logoClass " hidden dark:flex") -}} + {{- if $logo_dark -}} + {{- $logoClass = (print $logoClass " dark:hidden" ) -}} + {{- end }} + {{- if or $logo $logo_dark -}} + + {{- end }} + {{- with $logo }} + {{- partial "picture.html" (dict "img" . "alt" $logoAlt "class" $logoClass "lazy" false "webp" false ) -}} + {{- end -}} + {{- with $logo_dark }} + {{- partial "picture.html" (dict "img" . "alt" $logoAlt "class" $logoDarkClass "lazy" false "webp" false ) -}} + {{- end -}} + {{- if or $logo $logo_dark -}} {{- end }} {{- end }} -{{- if .Site.Params.header.showTitle | default true }} +{{- if $.Page.Site.Params.header.showTitle | default true }} {{ .Site.Title | markdownify | emojify }} -{{- end }} +{{- end }} \ No newline at end of file