From 8f373e6c6d3f9d322041ba4d949c1b0c39ae8ea0 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 8 Jan 2021 11:45:30 +0100 Subject: Added section link to the header in regular pages, improved template structure, improved CSS variable names, keep prefix for specific page items on mobile --- scripts/metadata_filter.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts') 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) end function create_main_menu_state(section, main_menu) + local active_item = nil + for i = 1, #main_menu do local item = main_menu[i] local active = pandoc.utils.stringify(item.id) == section.id item.active = pandoc.MetaBool(active) + if active then + active_item = item + end end - return main_menu:filter(function(item) - return not item.hidden or item.active - end) + return pandoc.MetaMap({ + items = main_menu:filter(function(item) + return not item.hidden or item.active + end), + active = active_item + }) end function organize_subpages(pages) -- cgit v1.2.3-70-g09d2