summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata_filter.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 4abb716..fb7b3c9 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -137,15 +137,23 @@ function resolve_category(categories, category)
137end 137end
138 138
139function create_main_menu_state(section, main_menu) 139function create_main_menu_state(section, main_menu)
140 local active_item = nil
141
140 for i = 1, #main_menu do 142 for i = 1, #main_menu do
141 local item = main_menu[i] 143 local item = main_menu[i]
142 local active = pandoc.utils.stringify(item.id) == section.id 144 local active = pandoc.utils.stringify(item.id) == section.id
143 item.active = pandoc.MetaBool(active) 145 item.active = pandoc.MetaBool(active)
146 if active then
147 active_item = item
148 end
144 end 149 end
145 150
146 return main_menu:filter(function(item) 151 return pandoc.MetaMap({
147 return not item.hidden or item.active 152 items = main_menu:filter(function(item)
148 end) 153 return not item.hidden or item.active
154 end),
155 active = active_item
156 })
149end 157end
150 158
151function organize_subpages(pages) 159function organize_subpages(pages)