diff options
author | Volpeon <git@volpeon.ink> | 2022-06-13 08:43:35 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2022-06-13 08:43:35 +0200 |
commit | af3b016717605153abf786390f9fa3d77ce402e0 (patch) | |
tree | 78382adbefd20bc652721720a1d821189b11c22f | |
parent | Update (diff) | |
download | volpeon.ink-af3b016717605153abf786390f9fa3d77ce402e0.tar.gz volpeon.ink-af3b016717605153abf786390f9fa3d77ce402e0.tar.bz2 volpeon.ink-af3b016717605153abf786390f9fa3d77ce402e0.zip |
Control list flattening via metadata
-rw-r--r-- | assets/css/components/_card.scss | 2 | ||||
-rw-r--r-- | content/art/index.md | 13 | ||||
-rw-r--r-- | content/notebook/index.md | 11 | ||||
-rw-r--r-- | 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 @@ | |||
134 | position: relative; | 134 | position: relative; |
135 | width: 100%; | 135 | width: 100%; |
136 | height: 2em; | 136 | height: 2em; |
137 | padding-top: 50%; | 137 | padding-top: 46%; |
138 | } | 138 | } |
139 | 139 | ||
140 | @include iro.bem-elem('thumbnail-img') { | 140 | @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 @@ | |||
1 | --- | 1 | --- |
2 | title: Art | 2 | title: Art |
3 | position: 2 | 3 | position: 2 |
4 | list_layout: gallery-3 | 4 | list_layout: gallery-3 |
5 | list_order: date_desc | 5 | list_order: date_desc |
6 | list_limit: 6 | 6 | list_flatten: true |
7 | feed: true | 7 | list_limit: 6 |
8 | feed: true | ||
8 | --- | 9 | --- |
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 @@ | |||
1 | --- | 1 | --- |
2 | title: Notebook | 2 | title: Notebook |
3 | position: 3 | 3 | position: 3 |
4 | list_limit: 4 | 4 | list_limit: 4 |
5 | list_order: date_desc | 5 | list_order: date_desc |
6 | feed: true | 6 | list_flatten: true |
7 | feed: true | ||
7 | --- | 8 | --- |
8 | 9 | ||
9 | Random thoughts, ordered and unordered. | 10 | 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) | |||
27 | return result | 27 | return result |
28 | end | 28 | end |
29 | 29 | ||
30 | function dump(o) | ||
31 | if type(o) == 'table' then | ||
32 | local s = '{ ' | ||
33 | for k, v in pairs(o) do | ||
34 | if type(k) ~= 'number' then k = '"' .. k .. '"' end | ||
35 | s = s .. '[' .. k .. '] = ' .. dump(v) .. ',' | ||
36 | end | ||
37 | return s .. '} ' | ||
38 | else | ||
39 | return tostring(o) | ||
40 | end | ||
41 | end | ||
42 | |||
30 | function page_sort(order) | 43 | function page_sort(order) |
31 | return function(p1, p2) | 44 | return function(p1, p2) |
32 | if p1.position then | 45 | if p1.position then |
@@ -241,10 +254,10 @@ function generate_list(meta) | |||
241 | return meta.pages.all | 254 | return meta.pages.all |
242 | :map(function(cat) | 255 | :map(function(cat) |
243 | local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) | 256 | local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) |
244 | if c.pages then | 257 | if not c.pages or not cat.list_flatten then |
245 | return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) | ||
246 | else | ||
247 | return pandoc.List({ d1_page_to_list_item(cat, c) }) | 258 | return pandoc.List({ d1_page_to_list_item(cat, c) }) |
259 | else | ||
260 | return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) | ||
248 | end | 261 | end |
249 | end) | 262 | end) |
250 | allItems:sort(page_sort(cat.list_order)) | 263 | allItems:sort(page_sort(cat.list_order)) |