Skip to content

Commit

Permalink
refactor: simplify code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lxndrblz committed May 13, 2022
1 parent 4804436 commit f646f16
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
<nav class="nav">
<ul class="nav__list" id="navMenu">
{{ $url := .RelPermalink }}
{{ $current := . }}
{{ $menuId := 0}}
{{ range .Site.Menus.main }}
{{ $active := eq $url .URL }}
{{ $menuId = add $menuId 1 }}
{{ if .HasChildren }}
{{ range $menuId, $menuItem := .Site.Menus.main }}
{{ $active := eq $url $menuItem.URL }}
{{ if $menuItem.HasChildren }}

<li class="nav__list-item">
<div class="optionswitch">
<input class="optionswitch__picker" type="checkbox" id="{{ $menuId }}" hidden />

{{ $labelClass := "optionswitch__label" }}
{{ range .Children }}
{{ range $menuItem.Children }}
{{ if eq $url .URL }}
{{ $labelClass = "optionswitch__label nav__link--active" }}

Expand All @@ -36,12 +33,12 @@
{{ end }}

<label class="{{ $labelClass }}" for="{{ $menuId }}"
>{{ .Name }} <i class="fa fa-angle-down" aria-hidden="true"></i
>{{ $menuItem.Name }} <i class="fa fa-angle-down" aria-hidden="true"></i
></label>

<div class="optionswitch__triangle"></div>
<ul class="optionswitch__list">
{{ range .Children }}
{{ range $menuItem.Children }}
<li class="optionswitch__list-item">
<a
href="{{ .URL }}"
Expand Down Expand Up @@ -72,7 +69,7 @@

{{ end }}
title="{{ .Title }}"
>{{ .Name }}</a
>{{ $menuItem.Name }}</a
>
</li>

Expand Down

0 comments on commit f646f16

Please sign in to comment.