From 513002c44eabf8279eee0f72314fa3192b4a6090 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 21 Jul 2022 10:23:35 +0200 Subject: Moved emojis to art, set up up redirects --- scripts/metadata.lua | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/metadata.lua b/scripts/metadata.lua index 4b77541..872034c 100644 --- a/scripts/metadata.lua +++ b/scripts/metadata.lua @@ -146,21 +146,21 @@ function prep_menu(active_id, main_menu) end function process_pages(global, order, pages_by_id) - if not pages_by_id then return nil end - local pages_all = pandoc.List() local pages_date_desc = pandoc.List() - for _, page in pairs(pages_by_id) do - local p = process(global, page) - if not p.unlisted then - pages_all:insert(p) - if p.last_update then pages_date_desc:insert(p) end + if pages_by_id then + for _, page in pairs(pages_by_id) do + local p = process(global, page) + if not p.unlisted then + pages_all:insert(p) + if p.last_update then pages_date_desc:insert(p) end + end end - end - pages_all:sort(page_sort(order)) - pages_date_desc:sort(page_sort("date_desc")) + pages_all:sort(page_sort(order)) + pages_date_desc:sort(page_sort("date_desc")) + end local pages_data = { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id } @@ -170,7 +170,7 @@ end function find_depth(pages) local depth = 0 - if pages then + if #pages.all ~= 0 then for i = 1, #pages.all do local p = pages.all[i] local d = tonumber(p.depth) @@ -250,8 +250,7 @@ function generate_list(meta) if meta.depth == 2 then return meta.pages.all :map(function(cat) - local allItems = ((cat.pages and cat.pages.all) or pandoc.List()) - :map(function(p) return d2_page_to_list_item(meta, cat, p, false) end) + local allItems = cat.pages.all:map(function(p) return d2_page_to_list_item(meta, cat, p, false) end) return cat_to_list_cat(cat, allItems) end) @@ -261,11 +260,11 @@ function generate_list(meta) if meta.depth == 3 then return meta.pages.all :map(function(cat) - local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) - if not c.pages or not cat.list_flatten then - return pandoc.List({ d1_page_to_list_item(cat, c) }) - else + local allItems = cat.pages.all:flatMap(function(c) + if #c.pages.all ~= 0 and cat.list_flatten then return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) + else + return pandoc.List({ d1_page_to_list_item(cat, c) }) end end) allItems:sort(page_sort(cat.list_order)) @@ -318,7 +317,7 @@ function process(global, meta) if meta.last_update then meta.last_update = format_date(meta.last_update) - elseif meta.pages and #meta.pages.date_desc ~= 0 then + elseif #meta.pages.date_desc ~= 0 then meta.last_update = meta.pages.date_desc[1].last_update elseif meta.date then meta.last_update = format_date(meta.date) -- cgit v1.2.3-70-g09d2