Skip to content

Commit c979586

Browse files
authored
refactor: extract navbar title as individual partial component (#718)
* feat: navbar title * fix: navbar title --------- Co-authored-by: Floren Munteanu <[email protected]>
1 parent 7610118 commit c979586

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

layouts/_partials/custom/navbar-title.html

Whitespace-only changes.

layouts/_partials/navbar-title.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- $logoPath := .Site.Params.navbar.logo.path | default "images/logo.svg" -}}
2+
{{- $logoLink := .Site.Params.navbar.logo.link | default .Site.Home.RelPermalink -}}
3+
{{- $logoWidth := .Site.Params.navbar.logo.width | default "20" -}}
4+
{{- $logoHeight := .Site.Params.navbar.logo.height | default "20" -}}
5+
{{- $logoDarkPath := .Site.Params.navbar.logo.dark | default $logoPath -}}
6+
7+
<a class="hx:flex hx:items-center hx:hover:opacity-75 hx:ltr:mr-auto hx:rtl:ml-auto" href="{{ $logoLink }}">
8+
{{- $displayTitle := (.Site.Params.navbar.displayTitle | default true) }}
9+
{{- if (.Site.Params.navbar.displayLogo | default true) }}
10+
<img class="hx:mr-2 hx:block hx:dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ cond $displayTitle `Logo` .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
11+
<img class="hx:mr-2 hx:hidden hx:dark:block" src="{{ $logoDarkPath | relURL }}" alt="{{ cond $displayTitle `Dark Logo` .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
12+
{{- end }}
13+
{{- if $displayTitle }}
14+
<span class="hx:mr-2 hx:font-extrabold hx:inline hx:select-none" title="{{ .Site.Title }}">{{- .Site.Title -}}</span>
15+
{{- end }}
16+
</a>

layouts/_partials/navbar.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
{{- $logoPath := .Site.Params.navbar.logo.path | default "images/logo.svg" -}}
2-
{{- $logoLink := .Site.Params.navbar.logo.link | default .Site.Home.RelPermalink -}}
3-
{{- $logoWidth := .Site.Params.navbar.logo.width | default "20" -}}
4-
{{- $logoHeight := .Site.Params.navbar.logo.height | default "20" -}}
5-
{{- $logoDarkPath := .Site.Params.navbar.logo.dark | default $logoPath -}}
6-
71
{{- $navWidth := "hx:max-w-[90rem]" -}}
82
{{- with .Site.Params.navbar.width -}}
93
{{ if eq . "normal" -}}
@@ -20,16 +14,7 @@
2014
></div>
2115

2216
<nav class="hextra-max-navbar-width hx:mx-auto hx:flex hx:items-center hx:justify-end hx:gap-2 hx:h-16 hx:px-6">
23-
<a class="hx:flex hx:items-center hx:hover:opacity-75 hx:ltr:mr-auto hx:rtl:ml-auto" href="{{ $logoLink }}">
24-
{{- $displayTitle := (.Site.Params.navbar.displayTitle | default true) }}
25-
{{- if (.Site.Params.navbar.displayLogo | default true) }}
26-
<img class="hx:mr-2 hx:block hx:dark:hidden" src="{{ $logoPath | relURL }}" alt="{{ cond $displayTitle `Logo` .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
27-
<img class="hx:mr-2 hx:hidden hx:dark:block" src="{{ $logoDarkPath | relURL }}" alt="{{ cond $displayTitle `Dark Logo` .Site.Title }}" height="{{ $logoHeight }}" width="{{ $logoWidth }}" />
28-
{{- end }}
29-
{{- if $displayTitle }}
30-
<span class="hx:mr-2 hx:font-extrabold hx:inline hx:select-none" title="{{ .Site.Title }}">{{- .Site.Title -}}</span>
31-
{{- end }}
32-
</a>
17+
{{ partial "navbar-title.html" . }}
3318

3419
{{- $currentPage := . -}}
3520
{{- range .Site.Menus.main -}}

0 commit comments

Comments
 (0)