From 31992bdba775fc3022a858ace9743620e70aee17 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 10 Jul 2022 18:51:39 +0200 Subject: Fixed date handling --- content/notebook/scrap/design-test.md | 2 +- filters/emojis.lua | 6 ++---- scripts/metadata.lua | 22 +++++++++++----------- templates/partials/gallery_card.html | 6 +++--- templates/partials/grid_card.html | 6 +++--- templates/partials/list_card.html | 10 +++++----- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/content/notebook/scrap/design-test.md b/content/notebook/scrap/design-test.md index c7c05ca..d618085 100644 --- a/content/notebook/scrap/design-test.md +++ b/content/notebook/scrap/design-test.md @@ -1,7 +1,7 @@ --- schema_type: DigitalDocument title: Markdown Test Page -last_update: 2021-12-16 +date: 2021-12-16 --- - [Headings](#headings) diff --git a/filters/emojis.lua b/filters/emojis.lua index 5eb9d4b..427d04b 100644 --- a/filters/emojis.lua +++ b/filters/emojis.lua @@ -1,15 +1,13 @@ -local common = require 'filters.lib.common' - function Str(el) local prefix, emojiref, suffix = el.text:match('^(.*):([^ ]+):(.*)$') if emojiref then local els = pandoc.List() - + els:insert(pandoc.Str(prefix)) els:insert(pandoc.Image(emojiref, "/emojis/" .. emojiref .. ".png", emojiref, { class = 'o-emoji' })) els:insert(pandoc.Str(suffix)) - + return els end 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) diff --git a/templates/partials/gallery_card.html b/templates/partials/gallery_card.html index 4aa274a..3020c2d 100644 --- a/templates/partials/gallery_card.html +++ b/templates/partials/gallery_card.html @@ -36,10 +36,10 @@ $if(it.thumbnail)$ $elseif(it.category)$ $it.category$ $it.title$ - $elseif(it.date)$ + $elseif(it.last_update)$ - $it.title$ diff --git a/templates/partials/grid_card.html b/templates/partials/grid_card.html index 4120169..abcd923 100644 --- a/templates/partials/grid_card.html +++ b/templates/partials/grid_card.html @@ -23,10 +23,10 @@ $if(it.url)$ $elseif(it.category)$ $it.category$ $it.title$ - $elseif(it.date)$ + $elseif(it.last_update)$ - $it.title$ diff --git a/templates/partials/list_card.html b/templates/partials/list_card.html index 539b7d3..755686f 100644 --- a/templates/partials/list_card.html +++ b/templates/partials/list_card.html @@ -23,9 +23,9 @@ $if(it.url)$ $elseif(it.category)$ $it.category$ $it.title$ - $elseif(it.date)$ + $elseif(it.last_update)$ - + $it.title$ $else$ @@ -45,10 +45,10 @@ $if(it.url)$ $it.category$ - $elseif(it.date)$ + $elseif(it.last_update)$ - $endif$ -- cgit v1.2.3-70-g09d2