From 31992bdba775fc3022a858ace9743620e70aee17 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 10 Jul 2022 18:51:39 +0200 Subject: Fixed date handling --- scripts/metadata.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'scripts/metadata.lua') diff --git a/scripts/metadata.lua b/scripts/metadata.lua index 8f32bd4..4b77541 100644 --- a/scripts/metadata.lua +++ b/scripts/metadata.lua @@ -187,8 +187,8 @@ function d1_page_to_list_item(meta, p) return { title = p.title, subtitle = p.subtitle, - date = p.date, - last_update = p.last_update, + date = meta.list_order == "date_desc" and p.date, + last_update = meta.list_order == "date_desc" and p.last_update, schema_type = p.schema_type, position = p.position, url = p.url, @@ -206,8 +206,8 @@ function d2_page_to_list_item(meta, cat, p, set_cat_title) title = p.title, subtitle = p.subtitle, category = set_cat_title and cat.title, - date = p.date, - last_update = p.last_update, + date = cat.list_order == "date_desc" and p.date, + last_update = cat.list_order == "date_desc" and p.last_update, schema_type = p.schema_type, position = p.position, url = p.url, @@ -316,18 +316,18 @@ function process(global, meta) meta.depth = find_depth(meta.pages) meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth)) - if meta.date then - meta.date = format_date(meta.date) - elseif meta.pages and #meta.pages.date_desc ~= 0 then - meta.date = meta.pages.date_desc[1].date - end - if meta.last_update then meta.last_update = format_date(meta.last_update) elseif meta.pages and #meta.pages.date_desc ~= 0 then meta.last_update = meta.pages.date_desc[1].last_update elseif meta.date then - meta.last_update = meta.date + meta.last_update = format_date(meta.date) + end + + if meta.date then + meta.date = format_date(meta.date) + elseif meta.last_update then + meta.date = meta.last_update end meta.list = generate_list(meta) -- cgit v1.2.3-54-g00ecf