From 38fc7544451708ec80286dca47cfdcfa7d9dd95a Mon Sep 17 00:00:00 2001 From: hossainemruz Date: Fri, 26 Mar 2021 23:59:55 +0600 Subject: [PATCH] Add helper function for generating section ID Signed-off-by: hossainemruz --- layouts/partials/helpers/get-section-id.html | 5 +++++ layouts/partials/navigators/navbar.html | 12 ++---------- 2 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 layouts/partials/helpers/get-section-id.html diff --git a/layouts/partials/helpers/get-section-id.html b/layouts/partials/helpers/get-section-id.html new file mode 100644 index 0000000..2dc13ab --- /dev/null +++ b/layouts/partials/helpers/get-section-id.html @@ -0,0 +1,5 @@ +{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} +{{ return $sectionID }} \ No newline at end of file diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index fef2560..303aa3a 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -60,12 +60,8 @@ {{ if and (.section.enable) (.section.showOnNavbar)}} {{ $sectionCount = add $sectionCount 1}} {{ if lt $sectionCount 5 }} - {{ $sectionID := replace (lower .section.name) " " "-" }} - {{ if .section.id }} - {{ $sectionID = .section.id }} - {{ end }} {{ end }} {{ end }} @@ -78,12 +74,8 @@ {{ range sort $sections "section.weight" }} {{ if and (.section.enable) (.section.showOnNavbar) }} {{ $sectionCount = add $sectionCount 1}} - {{ $sectionID := replace (lower .section.name) " " "-" }} - {{ if .section.id }} - {{ $sectionID = .section.id }} - {{ end }} {{ if gt $sectionCount 5 }} - {{ .section.name }} + {{ .section.name }} {{ end }} {{ end }} {{- end }}