From c2ddbce74e8ae0f2f688497715e2382704ae7300 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 4 Aug 2022 12:08:04 +0200 Subject: Show page date depending on list layout --- scripts/metadata.lua | 10 ++++++---- scripts/page.lua | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/metadata.lua b/scripts/metadata.lua index 5157677..afd0ca5 100644 --- a/scripts/metadata.lua +++ b/scripts/metadata.lua @@ -76,7 +76,7 @@ function process_pages(global, build, meta) local pages_date_desc = pandoc.List() for id, p in pairs(meta.pages) do - process(global, build, p) + process(global, build, p, meta) if not p.unlisted then pages_all:insert(id) @@ -126,7 +126,7 @@ function resolve_dates(meta) meta.was_updated = meta.date and meta.last_update and meta.date.yyyy_mm_dd ~= meta.last_update.yyyy_mm_dd end -function process_base(build, meta) +function process_base(build, meta, parent) meta.namespace = prep_namespace(meta.namespace) meta.file_out = utils.stringify(meta.file_out) meta.unlisted = meta.unlisted or (meta.draft and build.mode ~= "dev") @@ -136,13 +136,15 @@ function process_base(build, meta) meta.slug = slug(meta.title) meta.schema_type = meta.schema_type or "CreativeWork" meta.list_layout = prep_layout(meta.list_layout or "list") + meta.list_order = meta.list_order and utils.stringify(meta.list_order) meta.position = meta.position and tonumber(utils.stringify(meta.position)) 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.show_date = parent and parent.list_order == "date_desc" end -function process(global, build, meta) - process_base(build, meta) +function process(global, build, meta, parent) + process_base(build, meta, parent) process_pages(global, build, meta) resolve_dates(meta) end diff --git a/scripts/page.lua b/scripts/page.lua index 3df55ec..3f77464 100644 --- a/scripts/page.lua +++ b/scripts/page.lua @@ -73,7 +73,7 @@ function d1_page_to_list_item(meta, p) subtitle = p.subtitle, date = p.date, last_update = p.last_update, - show_date = meta.list_order == "date_desc", + show_date = p.show_date, schema_type = p.schema_type, draft = p.draft, position = p.position, @@ -94,7 +94,7 @@ function d2_page_to_list_item(meta, cat, p, set_cat_title) category = set_cat_title and cat.title, date = p.date, last_update = p.last_update, - show_date = cat.list_order == "date_desc", + show_date = p.show_date, schema_type = p.schema_type, draft = p.draft, position = p.position, -- cgit v1.2.3-70-g09d2