mirror of
https://github.com/imfing/hextra.git
synced 2025-07-01 15:37:46 -04:00
fix: generate mobile nav data
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
{{/* Generate mobile navigation data based on main menu */}}
|
||||
|
||||
{{- $context := . -}}
|
||||
|
||||
{{- $data := slice -}}
|
||||
|
||||
{{- range .Site.Menus.main -}}
|
||||
{{- if not (eq .Params.type "search") -}}
|
||||
{{- $title := or (T .Identifier) .Name -}}
|
||||
{{- $link := .URL -}}
|
||||
{{- $external := strings.HasPrefix $link "http" -}}
|
||||
{{- with .PageRef -}}
|
||||
{{- if hasPrefix . "/" -}}
|
||||
{{- $link = relLangURL (strings.TrimPrefix "/" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with .Page -}}
|
||||
{{- $page := . -}}
|
||||
|
||||
{{- if and $page.IsSection (eq $page.Type "docs") -}}
|
||||
{{- $page = (partial "utils/translated-page" (dict "page" $page "lang" site.Language.LanguageCode)) -}}
|
||||
{{- $sectionData := (partial "components/sidebar/generate-section-data" $page) | unmarshal -}}
|
||||
{{- $data = $data | append (dict "title" $title "link" $link "items" $sectionData) -}}
|
||||
{{- else -}}
|
||||
{{- $data = $data | append (dict "title" $title "link" $link) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* TODO: handle other cases like external links */}}
|
||||
{{- $data = $data | append (dict "title" $title "link" $link) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return ($data | jsonify (dict "noHTMLEscape" true)) -}}
|
Reference in New Issue
Block a user