summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata.lua35
1 files changed, 17 insertions, 18 deletions
diff --git a/scripts/metadata.lua b/scripts/metadata.lua
index 4b77541..872034c 100644
--- a/scripts/metadata.lua
+++ b/scripts/metadata.lua
@@ -146,21 +146,21 @@ function prep_menu(active_id, main_menu)
146end 146end
147 147
148function process_pages(global, order, pages_by_id) 148function process_pages(global, order, pages_by_id)
149 if not pages_by_id then return nil end
150
151 local pages_all = pandoc.List() 149 local pages_all = pandoc.List()
152 local pages_date_desc = pandoc.List() 150 local pages_date_desc = pandoc.List()
153 151
154 for _, page in pairs(pages_by_id) do 152 if pages_by_id then
155 local p = process(global, page) 153 for _, page in pairs(pages_by_id) do
156 if not p.unlisted then 154 local p = process(global, page)
157 pages_all:insert(p) 155 if not p.unlisted then
158 if p.last_update then pages_date_desc:insert(p) end 156 pages_all:insert(p)
157 if p.last_update then pages_date_desc:insert(p) end
158 end
159 end 159 end
160 end
161 160
162 pages_all:sort(page_sort(order)) 161 pages_all:sort(page_sort(order))
163 pages_date_desc:sort(page_sort("date_desc")) 162 pages_date_desc:sort(page_sort("date_desc"))
163 end
164 164
165 local pages_data = { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id } 165 local pages_data = { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id }
166 166
@@ -170,7 +170,7 @@ end
170function find_depth(pages) 170function find_depth(pages)
171 local depth = 0 171 local depth = 0
172 172
173 if pages then 173 if #pages.all ~= 0 then
174 for i = 1, #pages.all do 174 for i = 1, #pages.all do
175 local p = pages.all[i] 175 local p = pages.all[i]
176 local d = tonumber(p.depth) 176 local d = tonumber(p.depth)
@@ -250,8 +250,7 @@ function generate_list(meta)
250 if meta.depth == 2 then 250 if meta.depth == 2 then
251 return meta.pages.all 251 return meta.pages.all
252 :map(function(cat) 252 :map(function(cat)
253 local allItems = ((cat.pages and cat.pages.all) or pandoc.List()) 253 local allItems = cat.pages.all:map(function(p) return d2_page_to_list_item(meta, cat, p, false) end)
254 :map(function(p) return d2_page_to_list_item(meta, cat, p, false) end)
255 254
256 return cat_to_list_cat(cat, allItems) 255 return cat_to_list_cat(cat, allItems)
257 end) 256 end)
@@ -261,11 +260,11 @@ function generate_list(meta)
261 if meta.depth == 3 then 260 if meta.depth == 3 then
262 return meta.pages.all 261 return meta.pages.all
263 :map(function(cat) 262 :map(function(cat)
264 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) 263 local allItems = cat.pages.all:flatMap(function(c)
265 if not c.pages or not cat.list_flatten then 264 if #c.pages.all ~= 0 and cat.list_flatten then
266 return pandoc.List({ d1_page_to_list_item(cat, c) })
267 else
268 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) 265 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end)
266 else
267 return pandoc.List({ d1_page_to_list_item(cat, c) })
269 end 268 end
270 end) 269 end)
271 allItems:sort(page_sort(cat.list_order)) 270 allItems:sort(page_sort(cat.list_order))
@@ -318,7 +317,7 @@ function process(global, meta)
318 317
319 if meta.last_update then 318 if meta.last_update then
320 meta.last_update = format_date(meta.last_update) 319 meta.last_update = format_date(meta.last_update)
321 elseif meta.pages and #meta.pages.date_desc ~= 0 then 320 elseif #meta.pages.date_desc ~= 0 then
322 meta.last_update = meta.pages.date_desc[1].last_update 321 meta.last_update = meta.pages.date_desc[1].last_update
323 elseif meta.date then 322 elseif meta.date then
324 meta.last_update = format_date(meta.date) 323 meta.last_update = format_date(meta.date)