Don't default logo into theme logo

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
hossainemruz 2021-06-05 23:42:28 +06:00
parent 0763f9b816
commit 63eb7dd4ed
4 changed files with 69 additions and 58 deletions

View file

@ -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}}
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" />
@ -30,7 +13,20 @@
<link href="https://fonts.googleapis.com/css2?family=Muli:wght@300;400;500;600" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Muli:wght@300;400;500;600" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" />
<!--================= custom style overrides =========================-->
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
<!--================= fab-icon =========================--> <!--================= fab-icon =========================-->
{{ 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}}
<link rel="icon" type="image/png" href="{{ $favicon }}" /> <link rel="icon" type="image/png" href="{{ $favicon }}" />
{{end}} {{end}}

View file

@ -1,30 +1,31 @@
{{ $logoEnabled := site.Params.logo.enable | default false }} {{/* by default don't use any logo */}}
{{ $mainLogo := "" }}
{{ $invertedLogo := "" }}
{{/* default logos */}} {{/* if custom logo has been provided, use them */}}
{{ $mainLogo := "/images/main-logo.png" }}
{{ $invertedLogo := "/images/inverted-logo.png" }}
{{/* if custom logo has been provided in the config file, then use them */}}
{{ if site.Params.logo.main }} {{ if site.Params.logo.main }}
{{ $mainLogo = site.Params.logo.main }} {{ $mainLogo = site.Params.logo.main }}
{{ end }} {{ end }}
{{ if site.Params.logo.inverted }} {{ if site.Params.logo.inverted }}
{{ $invertedLogo = site.Params.logo.inverted }} {{ $invertedLogo = site.Params.logo.inverted }}
{{ end }} {{ end }}
{{/* resize the logos. don't resize svg because it is not supported */}} {{/* resize the logos. don't resize svg because it is not supported */}}
{{ $mainLogo := resources.Get $mainLogo}} {{ if $mainLogo }}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} {{ $mainLogo = resources.Get $mainLogo}}
{{ $mainLogo = $mainLogo.Resize "42x" }} {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ end }} {{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ $invertedLogo := resources.Get $invertedLogo}} {{ if $invertedLogo }}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg") }} {{ $invertedLogo = resources.Get $invertedLogo}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }} {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ end }} {{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
<nav class="navbar navbar-expand-xl top-navbar final-navbar shadow"> <nav class="navbar navbar-expand-xl top-navbar final-navbar shadow">
<div class="container"> <div class="container">
@ -32,7 +33,7 @@
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}"> <a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
{{ if $logoEnabled }} {{ if $mainLogo }}
<img src="{{ $mainLogo }}" alt="Logo"> <img src="{{ $mainLogo }}" alt="Logo">
{{ end }} {{ end }}
{{- site.Title -}} {{- site.Title -}}
@ -49,9 +50,11 @@
</ul> </ul>
</div> </div>
</div> </div>
{{ if $logoEnabled }} <!-- Store the logo information in a hidden img for the JS -->
<!-- Store the logo information in a hidden img for the JS --> {{ if $mainLogo }}
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo"> <img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo"> {{ end }}
{{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ end }} {{ end }}
</nav> </nav>

View file

@ -1,18 +1,17 @@
{{/* variables for enabling/disabling various features */}} {{/* variables for enabling/disabling various features */}}
{{ $blogEnabled := site.Params.features.blog.enable | default false }} {{ $blogEnabled := site.Params.features.blog.enable | default false }}
{{ $notesEnabled := site.Params.features.notes.enable | default false }} {{ $notesEnabled := site.Params.features.notes.enable | default false }}
{{ $logoEnabled := site.Params.logo.enable | default false }}
{{/* keep backward compatibility for blog post */}} {{/* keep backward compatibility for blog post */}}
{{ if site.Params.enableBlogPost }} {{ if site.Params.enableBlogPost }}
{{ $blogEnabled = true }} {{ $blogEnabled = true }}
{{ end }} {{ end }}
{{/* default logos */}} {{/* by default don't use any logo */}}
{{ $mainLogo := "/images/main-logo.png" }} {{ $mainLogo := "" }}
{{ $invertedLogo := "/images/inverted-logo.png" }} {{ $invertedLogo := "" }}
{{/* if custom logo is used, them */}} {{/* if custom logo has been provided, use them */}}
{{ if site.Params.logo.main }} {{ if site.Params.logo.main }}
{{ $mainLogo = site.Params.logo.main }} {{ $mainLogo = site.Params.logo.main }}
{{ end }} {{ end }}
@ -21,17 +20,21 @@
{{ end }} {{ end }}
{{/* resize the logos. don't resize svg because it is not supported */}} {{/* resize the logos. don't resize svg because it is not supported */}}
{{ $mainLogo := resources.Get $mainLogo}} {{ if $mainLogo }}
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }} {{ $mainLogo = resources.Get $mainLogo}}
{{ $mainLogo = $mainLogo.Resize "42x" }} {{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
{{ $mainLogo = $mainLogo.Resize "42x" }}
{{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ end }} {{ end }}
{{ $mainLogo = $mainLogo.RelPermalink}}
{{ $invertedLogo := resources.Get $invertedLogo}} {{ if $invertedLogo }}
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}} {{ $invertedLogo = resources.Get $invertedLogo}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }} {{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
{{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ end }} {{ end }}
{{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ $customMenus := site.Params.customMenus }} {{ $customMenus := site.Params.customMenus }}
{{ if (index site.Data site.Language.Lang).site.customMenus }} {{ if (index site.Data site.Language.Lang).site.customMenus }}
@ -46,7 +49,7 @@
<nav class="navbar navbar-expand-xl top-navbar initial-navbar" id="top-navbar"> <nav class="navbar navbar-expand-xl top-navbar initial-navbar" id="top-navbar">
<div class="container"> <div class="container">
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}"> <a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
{{ if $logoEnabled }} {{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" id="logo" alt="Logo"> <img src="{{ $invertedLogo }}" id="logo" alt="Logo">
{{ end }} {{ end }}
{{- site.Title -}} {{- site.Title -}}
@ -121,9 +124,11 @@
</ul> </ul>
</div> </div>
</div> </div>
{{ if $logoEnabled }} <!-- Store the logo information in a hidden img for the JS -->
<!-- Store the logo information in a hidden img for the JS --> {{ if $mainLogo }}
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo"> <img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
{{ end }}
{{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo"> <img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ end }} {{ end }}
</nav> </nav>

View file

@ -16,8 +16,12 @@
$('#navbar-toggler').addClass('navbar-light'); $('#navbar-toggler').addClass('navbar-light');
// get the main logo from hidden img tag // get the main logo from hidden img tag
let mainLogo = document.getElementById("main-logo").getAttribute("src"); let mainLogo = document.getElementById("main-logo")
$('#logo').attr("src", mainLogo); if (mainLogo !== null) {
let logoURL = mainLogo.getAttribute("src");
$('#logo').attr("src", logoURL);
}
} else { } else {
$('#top-navbar').removeClass('final-navbar shadow'); $('#top-navbar').removeClass('final-navbar shadow');
$('#top-navbar').addClass('initial-navbar'); $('#top-navbar').addClass('initial-navbar');
@ -26,8 +30,11 @@
$('#navbar-toggler').addClass('navbar-dark'); $('#navbar-toggler').addClass('navbar-dark');
// get the inverted logo from hidden img tag // get the inverted logo from hidden img tag
let invertedLogo = document.getElementById("inverted-logo").getAttribute("src"); let invertedLogo = document.getElementById("inverted-logo")
$('#logo').attr("src", invertedLogo); if (invertedLogo !== null) {
let logoURL = invertedLogo.getAttribute("src");
$('#logo').attr("src", logoURL);
}
} }
}); });