hextra/layouts/partials/components/sidebar/get-section-data.html

21 lines
580 B
HTML
Raw Normal View History

{{/* Get section sidebar config from Hugo `data` directory
2024-04-03 22:36:58 +00:00
If the site is multilingual, the sidebar data is stored in a language-specific
directory. For example, the English sidebar data is stored in `data/en/sidebar.yaml`.
*/}}
{{ $data := "" }}
2024-04-30 23:56:57 +01:00
{{ $section := .Section | default "index" }}
2024-04-30 23:54:06 +01:00
{{ $filename := "sidebar" }}
2024-04-03 22:36:58 +00:00
{{ if hugo.IsMultilingual }}
2024-04-30 23:54:06 +01:00
{{ with (index site.Data site.Language.Lang $filename $section) }}
2024-04-03 22:36:58 +00:00
{{ $data = . }}
{{ end }}
{{ else }}
2024-04-30 23:54:06 +01:00
{{ with (index site.Data $filename $section) }}
2024-04-03 22:36:58 +00:00
{{ $data = . }}
{{ end }}
{{ end }}
{{ return $data }}