diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/metadata_filter.lua | 14 |
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) | |||
137 | end | 137 | end |
138 | 138 | ||
139 | function create_main_menu_state(section, main_menu) | 139 | function 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 | }) | ||
149 | end | 157 | end |
150 | 158 | ||
151 | function organize_subpages(pages) | 159 | function organize_subpages(pages) |