Add helper function for generating section ID
Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
parent
d5c1729c88
commit
38fc754445
2 changed files with 7 additions and 10 deletions
5
layouts/partials/helpers/get-section-id.html
Normal file
5
layouts/partials/helpers/get-section-id.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{ $sectionID := replace (lower .section.name) " " "-" }}
|
||||
{{ if .section.id }}
|
||||
{{ $sectionID = .section.id }}
|
||||
{{ end }}
|
||||
{{ return $sectionID }}
|
|
@ -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 }}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#{{ $sectionID }}">{{ .section.name }}</a>
|
||||
<a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }} }}">{{ .section.name }}</a>
|
||||
</li>
|
||||
{{ 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 }}
|
||||
<a class="dropdown-item" href="#{{ $sectionID }}">{{ .section.name }}</a>
|
||||
<a class="dropdown-item" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue