mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-06 04:14:25 +00:00
refactor: docs menu name detection logic
Enables streamlining Academic docs front matter with just `menu: "updates"` for example.
This commit is contained in:
1 parent
7c87076824
commit
c74f07dd01
1 file changed
+6
-2
@@ -3,8 +3,12 @@
|
||||
{{/* Dynamically load menu for this docs page. */}}
|
||||
{{/* Attempt to get menu name from `menu_name` param, Hugo's front matter menu config, or the last dir of filepath. */}}
|
||||
{{ $menu_name := "" }}
|
||||
{{ range $k, $v := .Params.menu }}
|
||||
{{ $menu_name = $k }}
|
||||
{{ if .Params.menu | and (not (reflect.IsMap .Params.menu)) | and (not (reflect.IsSlice .Params.menu)) }}
|
||||
{{ $menu_name = .Params.menu }}
|
||||
{{ else if .Params.menu | and (or (reflect.IsMap .Params.menu) (reflect.IsSlice .Params.menu)) }}
|
||||
{{ range $k, $v := .Params.menu }}
|
||||
{{ $menu_name = $k }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $menu_name = .Params.menu_name | default $menu_name | default (path.Base (path.Split .File).Dir) }}
|
||||
{{ if not (index site.Menus $menu_name) }}
|
||||
|
||||
Reference in new issue
Block a user