From 63eb7dd4ed82469f403461374dede57d22b84b1e Mon Sep 17 00:00:00 2001 From: hossainemruz Date: Sat, 5 Jun 2021 23:42:28 +0600 Subject: [PATCH] Don't default logo into theme logo Signed-off-by: hossainemruz --- layouts/partials/header.html | 32 ++++++++--------- layouts/partials/navigators/navbar-2.html | 43 ++++++++++++----------- layouts/partials/navigators/navbar.html | 37 ++++++++++--------- static/js/navbar.js | 15 +++++--- 4 files changed, 69 insertions(+), 58 deletions(-) diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 904c905..b4a4123 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,20 +1,3 @@ -{{ $logoEnabled := site.Params.logo.enable | default false }} - -{{/* default favicon */}} -{{ $favicon := "/images/favicon.png" }} - -{{/* if favicon is provided in the config, then use that */}} -{{ if site.Params.logo.favicon }} - {{ $favicon = site.Params.logo.favicon }} -{{ end }} - -{{/* resize the favicon. don't resize svg because it is not supported */}} -{{ $favicon := resources.Get $favicon }} -{{ if and $favicon (ne $favicon.MediaType.SubType "svg") }} - {{ $favicon = $favicon.Resize "42x" }} -{{ end }} -{{ $favicon = $favicon.RelPermalink}} - @@ -30,7 +13,20 @@ + + + -{{ if $logoEnabled }} +{{/* add favicon only if the site author has provided the the favicon */}} +{{ if site.Params.logo.favicon }} + {{ $favicon := site.Params.logo.favicon }} + + {{/* resize the favicon. don't resize svg because it is not supported */}} + {{ $favicon = resources.Get $favicon }} + {{ if and $favicon (ne $favicon.MediaType.SubType "svg") }} + {{ $favicon = $favicon.Resize "42x" }} + {{ end }} + {{ $favicon = $favicon.RelPermalink}} + {{end}} diff --git a/layouts/partials/navigators/navbar-2.html b/layouts/partials/navigators/navbar-2.html index 9cc1363..d9cff26 100644 --- a/layouts/partials/navigators/navbar-2.html +++ b/layouts/partials/navigators/navbar-2.html @@ -1,30 +1,31 @@ -{{ $logoEnabled := site.Params.logo.enable | default false }} +{{/* by default don't use any logo */}} +{{ $mainLogo := "" }} +{{ $invertedLogo := "" }} -{{/* default logos */}} -{{ $mainLogo := "/images/main-logo.png" }} -{{ $invertedLogo := "/images/inverted-logo.png" }} - -{{/* if custom logo has been provided in the config file, then use them */}} +{{/* if custom logo has been provided, use them */}} {{ if site.Params.logo.main }} {{ $mainLogo = site.Params.logo.main }} {{ end }} - {{ if site.Params.logo.inverted }} {{ $invertedLogo = site.Params.logo.inverted }} {{ end }} {{/* resize the logos. don't resize svg because it is not supported */}} -{{ $mainLogo := resources.Get $mainLogo}} -{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} - {{ $mainLogo = $mainLogo.Resize "42x" }} +{{ if $mainLogo }} + {{ $mainLogo = resources.Get $mainLogo}} + {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} + {{ $mainLogo = $mainLogo.Resize "42x" }} + {{ end }} + {{ $mainLogo = $mainLogo.RelPermalink}} {{ end }} -{{ $mainLogo = $mainLogo.RelPermalink}} -{{ $invertedLogo := resources.Get $invertedLogo}} -{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg") }} - {{ $invertedLogo = $invertedLogo.Resize "42x" }} +{{ if $invertedLogo }} + {{ $invertedLogo = resources.Get $invertedLogo}} + {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}} + {{ $invertedLogo = $invertedLogo.Resize "42x" }} + {{ end }} + {{ $invertedLogo = $invertedLogo.RelPermalink}} {{ end }} -{{ $invertedLogo = $invertedLogo.RelPermalink}} diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index 49844e6..7d92580 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -1,18 +1,17 @@ {{/* variables for enabling/disabling various features */}} {{ $blogEnabled := site.Params.features.blog.enable | default false }} {{ $notesEnabled := site.Params.features.notes.enable | default false }} -{{ $logoEnabled := site.Params.logo.enable | default false }} {{/* keep backward compatibility for blog post */}} {{ if site.Params.enableBlogPost }} {{ $blogEnabled = true }} {{ end }} -{{/* default logos */}} -{{ $mainLogo := "/images/main-logo.png" }} -{{ $invertedLogo := "/images/inverted-logo.png" }} +{{/* by default don't use any logo */}} +{{ $mainLogo := "" }} +{{ $invertedLogo := "" }} -{{/* if custom logo is used, them */}} +{{/* if custom logo has been provided, use them */}} {{ if site.Params.logo.main }} {{ $mainLogo = site.Params.logo.main }} {{ end }} @@ -21,17 +20,21 @@ {{ end }} {{/* resize the logos. don't resize svg because it is not supported */}} -{{ $mainLogo := resources.Get $mainLogo}} -{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} - {{ $mainLogo = $mainLogo.Resize "42x" }} +{{ if $mainLogo }} + {{ $mainLogo = resources.Get $mainLogo}} + {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} + {{ $mainLogo = $mainLogo.Resize "42x" }} + {{ end }} + {{ $mainLogo = $mainLogo.RelPermalink}} {{ end }} -{{ $mainLogo = $mainLogo.RelPermalink}} -{{ $invertedLogo := resources.Get $invertedLogo}} -{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}} - {{ $invertedLogo = $invertedLogo.Resize "42x" }} +{{ if $invertedLogo }} + {{ $invertedLogo = resources.Get $invertedLogo}} + {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}} + {{ $invertedLogo = $invertedLogo.Resize "42x" }} + {{ end }} + {{ $invertedLogo = $invertedLogo.RelPermalink}} {{ end }} -{{ $invertedLogo = $invertedLogo.RelPermalink}} {{ $customMenus := site.Params.customMenus }} {{ if (index site.Data site.Language.Lang).site.customMenus }} @@ -46,7 +49,7 @@ diff --git a/static/js/navbar.js b/static/js/navbar.js index 929c74b..1d5ca97 100644 --- a/static/js/navbar.js +++ b/static/js/navbar.js @@ -16,8 +16,12 @@ $('#navbar-toggler').addClass('navbar-light'); // get the main logo from hidden img tag - let mainLogo = document.getElementById("main-logo").getAttribute("src"); - $('#logo').attr("src", mainLogo); + let mainLogo = document.getElementById("main-logo") + if (mainLogo !== null) { + let logoURL = mainLogo.getAttribute("src"); + $('#logo').attr("src", logoURL); + } + } else { $('#top-navbar').removeClass('final-navbar shadow'); $('#top-navbar').addClass('initial-navbar'); @@ -26,8 +30,11 @@ $('#navbar-toggler').addClass('navbar-dark'); // get the inverted logo from hidden img tag - let invertedLogo = document.getElementById("inverted-logo").getAttribute("src"); - $('#logo').attr("src", invertedLogo); + let invertedLogo = document.getElementById("inverted-logo") + if (invertedLogo !== null) { + let logoURL = invertedLogo.getAttribute("src"); + $('#logo').attr("src", logoURL); + } } });