summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/metadata_filter.lua28
1 files changed, 12 insertions, 16 deletions
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 4014db4..0ff7429 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -184,6 +184,8 @@ function find_depth(pages)
184end 184end
185 185
186function generate_list(meta) 186function generate_list(meta)
187 if not meta.pages then return nil end
188
187 if meta.depth == "1" then 189 if meta.depth == "1" then
188 return meta.pages.all:map(function(p) 190 return meta.pages.all:map(function(p)
189 return { 191 return {
@@ -203,7 +205,7 @@ function generate_list(meta)
203 content = cat.content, 205 content = cat.content,
204 url = cat.url, 206 url = cat.url,
205 grid = cat.list_grid, 207 grid = cat.list_grid,
206 items = cat.pages.all:map(function(p) 208 items = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p)
207 return { 209 return {
208 title = p.title, 210 title = p.title,
209 subtitle = p.subtitle, 211 subtitle = p.subtitle,
@@ -215,13 +217,15 @@ function generate_list(meta)
215 } 217 }
216 end), 218 end),
217 } 219 }
218 end) 220 end):filter(function(cat) return #cat.items ~= 0 end)
219 elseif meta.depth == "3" then 221 elseif meta.depth == "3" then
220 return meta.pages.all:map(function(cat) 222 return meta.pages.all:map(function(cat)
221 local items = pandoc.List() 223 return {
222 224 title = cat.title,
223 if cat.pages then 225 content = cat.content,
224 items = cat.pages.all:flatMap(function(c) 226 url = cat.url,
227 grid = cat.list_grid,
228 items = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c)
225 if c.pages then 229 if c.pages then
226 return c.pages.all:map(function(p) 230 return c.pages.all:map(function(p)
227 return { 231 return {
@@ -246,17 +250,9 @@ function generate_list(meta)
246 }) 250 })
247 return l 251 return l
248 end 252 end
249 end) 253 end),
250 end
251
252 return {
253 title = cat.title,
254 content = cat.content,
255 url = cat.url,
256 grid = cat.list_grid,
257 items = items,
258 } 254 }
259 end) 255 end):filter(function(cat) return #cat.items ~= 0 end)
260 end 256 end
261end 257end
262 258