summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-01-21 21:31:21 +0100
committerVolpeon <git@volpeon.ink>2021-01-21 21:31:21 +0100
commit1cc072bb0bca2e2a5e88ba05ee9b3ec39ea7eefc (patch)
tree1bccea4922f090ce120e83fe75f78010f7e08f05 /scripts
parentCompile drafts in watch/serve mode (diff)
downloadvolpeon.ink-1cc072bb0bca2e2a5e88ba05ee9b3ec39ea7eefc.tar.gz
volpeon.ink-1cc072bb0bca2e2a5e88ba05ee9b3ec39ea7eefc.tar.bz2
volpeon.ink-1cc072bb0bca2e2a5e88ba05ee9b3ec39ea7eefc.zip
Replace blogs with notebooks (i.e. no dates, grouped by category)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata_filter.lua25
1 files changed, 21 insertions, 4 deletions
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)
183 pandoc.utils.stringify(page.file_out)) 183 pandoc.utils.stringify(page.file_out))
184 end 184 end
185 185
186 local grouped_pages = group_by(pages, function(p) return not p.date end) 186 local pages_grouped_date =
187 group_by(pages, function(p) return not p.date end)
187 188
188 local pages_undated = grouped_pages[true] or pandoc.MetaList({}) 189 local pages_undated = pages_grouped_date[true] or pandoc.MetaList({})
189 pages_undated:sort(function(p1, p2) 190 pages_undated:sort(function(p1, p2)
190 return pandoc.utils.stringify(p1.title) < 191 return pandoc.utils.stringify(p1.title) <
191 pandoc.utils.stringify(p2.title) 192 pandoc.utils.stringify(p2.title)
192 end) 193 end)
193 194
194 local pages_dated = grouped_pages[false] or pandoc.MetaList({}) 195 local pages_dated = pages_grouped_date[false] or pandoc.MetaList({})
195 pages_dated:sort(function(p1, p2) 196 pages_dated:sort(function(p1, p2)
196 return pandoc.utils.stringify(p1.date.yyyy_mm_dd) > 197 return pandoc.utils.stringify(p1.date.yyyy_mm_dd) >
197 pandoc.utils.stringify(p2.date.yyyy_mm_dd) 198 pandoc.utils.stringify(p2.date.yyyy_mm_dd)
198 end) 199 end)
199 200
201 local pages_categorized = pages:filter(
202 function(p) return p.category ~= nil end)
203 pages_categorized:sort(function(p1, p2)
204 return pandoc.utils.stringify(p1.title) >
205 pandoc.utils.stringify(p2.title)
206 end)
207
200 local pages_by_year = group_by(pages_dated, function(p) 208 local pages_by_year = group_by(pages_dated, function(p)
201 return pandoc.utils.stringify(p.date.yyyy) 209 return pandoc.utils.stringify(p.date.yyyy)
202 end) 210 end)
@@ -205,14 +213,23 @@ function organize_subpages(site_url, output_dir, ref_file, pages)
205 return i1.key > i2.key 213 return i1.key > i2.key
206 end)) 214 end))
207 215
216 local pages_by_category = group_by(pages_categorized, function(p)
217 return pandoc.utils.stringify(p.category.id)
218 end)
219 pages_by_category = pandoc.MetaList(table_to_list(pages_by_category,
220 function(i1, i2)
221 return i1.key > i2.key
222 end))
223
208 local pages_data = pandoc.MetaMap({ 224 local pages_data = pandoc.MetaMap({
209 all_dated = pages_dated, 225 all_dated = pages_dated,
210 all_undated = pages_undated, 226 all_undated = pages_undated,
211 by_year = pages_by_year, 227 by_year = pages_by_year,
228 by_category = pages_by_category,
212 last_update = #pages_dated ~= 0 and pages_dated[1].last_update 229 last_update = #pages_dated ~= 0 and pages_dated[1].last_update
213 }) 230 })
214 231
215 local categories_data = group_by(pages_dated, function(p) 232 local categories_data = group_by(pages_categorized, function(p)
216 return p.category and pandoc.utils.stringify(p.category.id) 233 return p.category and pandoc.utils.stringify(p.category.id)
217 end, function(stats, _, p) 234 end, function(stats, _, p)
218 if not stats then 235 if not stats then