From 1cc072bb0bca2e2a5e88ba05ee9b3ec39ea7eefc Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 21 Jan 2021 21:31:21 +0100 Subject: Replace blogs with notebooks (i.e. no dates, grouped by category) --- scripts/metadata_filter.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index d7116dc..cd0c2f7 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -183,20 +183,28 @@ function organize_subpages(site_url, output_dir, ref_file, pages) pandoc.utils.stringify(page.file_out)) end - local grouped_pages = group_by(pages, function(p) return not p.date end) + local pages_grouped_date = + group_by(pages, function(p) return not p.date end) - local pages_undated = grouped_pages[true] or pandoc.MetaList({}) + local pages_undated = pages_grouped_date[true] or pandoc.MetaList({}) pages_undated:sort(function(p1, p2) return pandoc.utils.stringify(p1.title) < pandoc.utils.stringify(p2.title) end) - local pages_dated = grouped_pages[false] or pandoc.MetaList({}) + local pages_dated = pages_grouped_date[false] or pandoc.MetaList({}) pages_dated:sort(function(p1, p2) return pandoc.utils.stringify(p1.date.yyyy_mm_dd) > pandoc.utils.stringify(p2.date.yyyy_mm_dd) end) + local pages_categorized = pages:filter( + function(p) return p.category ~= nil end) + pages_categorized:sort(function(p1, p2) + return pandoc.utils.stringify(p1.title) > + pandoc.utils.stringify(p2.title) + end) + local pages_by_year = group_by(pages_dated, function(p) return pandoc.utils.stringify(p.date.yyyy) end) @@ -205,14 +213,23 @@ function organize_subpages(site_url, output_dir, ref_file, pages) return i1.key > i2.key end)) + local pages_by_category = group_by(pages_categorized, function(p) + return pandoc.utils.stringify(p.category.id) + end) + pages_by_category = pandoc.MetaList(table_to_list(pages_by_category, + function(i1, i2) + return i1.key > i2.key + end)) + local pages_data = pandoc.MetaMap({ all_dated = pages_dated, all_undated = pages_undated, by_year = pages_by_year, + by_category = pages_by_category, last_update = #pages_dated ~= 0 and pages_dated[1].last_update }) - local categories_data = group_by(pages_dated, function(p) + local categories_data = group_by(pages_categorized, function(p) return p.category and pandoc.utils.stringify(p.category.id) end, function(stats, _, p) if not stats then -- cgit v1.2.3-70-g09d2