From af3b016717605153abf786390f9fa3d77ce402e0 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Mon, 13 Jun 2022 08:43:35 +0200 Subject: Control list flattening via metadata --- assets/css/components/_card.scss | 2 +- content/art/index.md | 13 +++++++------ content/notebook/index.md | 11 ++++++----- scripts/metadata_filter.lua | 19 ++++++++++++++++--- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/assets/css/components/_card.scss b/assets/css/components/_card.scss index d317d1f..ab399d8 100644 --- a/assets/css/components/_card.scss +++ b/assets/css/components/_card.scss @@ -134,7 +134,7 @@ position: relative; width: 100%; height: 2em; - padding-top: 50%; + padding-top: 46%; } @include iro.bem-elem('thumbnail-img') { diff --git a/content/art/index.md b/content/art/index.md index 63032a3..9699145 100644 --- a/content/art/index.md +++ b/content/art/index.md @@ -1,8 +1,9 @@ --- -title: Art -position: 2 -list_layout: gallery-3 -list_order: date_desc -list_limit: 6 -feed: true +title: Art +position: 2 +list_layout: gallery-3 +list_order: date_desc +list_flatten: true +list_limit: 6 +feed: true --- diff --git a/content/notebook/index.md b/content/notebook/index.md index 77fed0b..b987880 100644 --- a/content/notebook/index.md +++ b/content/notebook/index.md @@ -1,9 +1,10 @@ --- -title: Notebook -position: 3 -list_limit: 4 -list_order: date_desc -feed: true +title: Notebook +position: 3 +list_limit: 4 +list_order: date_desc +list_flatten: true +feed: true --- Random thoughts, ordered and unordered. diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua index cb060fa..07f060c 100644 --- a/scripts/metadata_filter.lua +++ b/scripts/metadata_filter.lua @@ -27,6 +27,19 @@ function pandoc.List:take(n) return result end +function dump(o) + if type(o) == 'table' then + local s = '{ ' + for k, v in pairs(o) do + if type(k) ~= 'number' then k = '"' .. k .. '"' end + s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end +end + function page_sort(order) return function(p1, p2) if p1.position then @@ -241,10 +254,10 @@ function generate_list(meta) return meta.pages.all :map(function(cat) local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) - if c.pages then - return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) - else + if not c.pages or not cat.list_flatten then return pandoc.List({ d1_page_to_list_item(cat, c) }) + else + return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) end end) allItems:sort(page_sort(cat.list_order)) -- cgit v1.2.3-70-g09d2