From bf36287607cbe7d5d3e393943b0b79e3d2c4b113 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 5 Aug 2022 07:45:30 +0200 Subject: Stricter pruning, don't pre-calculate description field --- scripts/metadata.lua | 2 -- scripts/page.lua | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/metadata.lua b/scripts/metadata.lua index 5d372fc..d0a4f45 100644 --- a/scripts/metadata.lua +++ b/scripts/metadata.lua @@ -145,8 +145,6 @@ function process_base(build, meta) meta.thumbnail = meta.thumbnail and make_absolute("thumbnail." .. utils.stringify(meta.thumbnail), meta.file_out) meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth)) - meta.description = (meta.description and pandoc.MetaBlocks(pandoc.Para(meta.description))) or - (not meta.no_description and meta.content) meta.show_date = meta.parent and meta.parent.list_order == "date_desc" meta.category = meta.parent and meta.parent.title meta.icon = meta.icon or (meta.parent and meta.parent.icon) diff --git a/scripts/page.lua b/scripts/page.lua index 4eeebb2..f3802a2 100644 --- a/scripts/page.lua +++ b/scripts/page.lua @@ -79,7 +79,8 @@ function cat_to_list_cat(meta, allItems) return { title = meta.title, - description = meta.description, + description = (meta.description and pandoc.MetaBlocks(pandoc.Para(meta.description))) or + (not meta.no_description and meta.content), last_update = meta.last_update, schema_type = meta.schema_type, url = meta.url, @@ -191,23 +192,22 @@ function process(global, build, meta, dir) end end -function prune_pages(meta, n) - if n == 0 then - meta.pages = { - all = pandoc.List(), - date_desc = pandoc.List(), - random = pandoc.List(), - by_id = {} - } +function prune_pages(meta, up, down) + meta.pages.random = pandoc.List() + meta.pages.by_id = {} + + if down == 0 then + meta.pages.all = pandoc.List() + meta.pages.date_desc = pandoc.List() else for _, p in pairs(meta.pages.by_id) do - prune_pages(p, n - 1) + prune(p, up, down - 1) end end end function prune(meta, up, down) - prune_pages(meta, down) + prune_pages(meta, up, down) if up == 0 then meta.parent = nil -- cgit v1.2.3-54-g00ecf