diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index b5926fd2..d7ea6025 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -46,10 +46,6 @@ org_name = "" # Description for social sharing and search engines. If undefined, superuser role is used in place. description = "" -# Display a logo in navigation bar rather than title (optional). -# To enable, place an image in `static/img/` and reference its filename below. To disable, set the value to "". -logo = "" - ############################ ## Site Features ############################ diff --git a/layouts/partials/functions/get_logo.html b/layouts/partials/functions/get_logo.html new file mode 100644 index 00000000..4bf6b8e6 --- /dev/null +++ b/layouts/partials/functions/get_logo.html @@ -0,0 +1,16 @@ +{{/* Function to get logo image. */}} +{{/* Inputs: constraint: max_height/fit (str); size (int) */}} +{{/* Output: resource (obj) */}} + +{{ $logo := resources.Get "images/logo.png" }} +{{ $logo_proc := $logo }} + +{{ if eq .constraint "max_height" }} + {{/* Resize logo to fit specified max height. */}} + {{ $logo_proc = ($logo.Resize (printf "x%s" (string .size))) }} +{{ else }} + {{/* Constrain logo to fit within specified dimensions. */}} + {{ $logo_proc = ($logo.Fit (printf "%sx%s" (string .size) (string .size))) }} +{{ end }} + +{{ return $logo_proc }} diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index e4977fe4..ec566f11 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -4,10 +4,12 @@
{{if $show_logo}} + {{ $has_logo := fileExists "assets/images/logo.png" }}
- {{- if site.Params.logo -}} - {{ site.Title }} + {{- if $has_logo -}} + {{ $logo := (partial "functions/get_logo" (dict "constraint" "max_height" "size" 70)) }} + {{ site.Title }} {{- else -}} {{- site.Title -}} {{- end -}} diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html index 9e51012d..f2a9f71a 100644 --- a/layouts/partials/site_head.html +++ b/layouts/partials/site_head.html @@ -148,6 +148,7 @@ {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} + {{ $has_logo := fileExists "assets/images/logo.png" }} {{ $og_image := "" }} {{ $twitter_card := "summary_large_image" }} {{ if $featured_image }} @@ -156,8 +157,8 @@ {{ $og_image = printf "img/%s" .Params.header.image | absURL }} {{ else if site.Params.sharing_image }} {{ $og_image = printf "img/%s" site.Params.sharing_image | absURL }} - {{ else if site.Params.logo }} - {{ $og_image = (printf "img/%s" site.Params.logo) | absURL }} + {{ else if $has_logo }} + {{ $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }} {{ $twitter_card = "summary" }} {{ else if site.Params.avatar }} {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }}