summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/scripts/metadata.lua b/scripts/metadata.lua
index a32ee29..27854b9 100644
--- a/scripts/metadata.lua
+++ b/scripts/metadata.lua
@@ -165,16 +165,26 @@ function process_pages(global, order, pages_by_id)
165 return { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id } 165 return { all = pages_all, date_desc = pages_date_desc, by_id = pages_by_id }
166end 166end
167 167
168function find_depth(pages) 168function find_depth(meta)
169 if meta.depth then
170 meta.depth = tonumber(meta.depth)
171 end
172
169 local depth = 0 173 local depth = 0
170 174
171 for i = 1, #pages.all do 175 if meta.pages then
172 local p = pages.all[i] 176 for _, page in pairs(meta.pages) do
173 local d = p.depth + 1 177 local p = find_depth(page)
174 if d > depth then depth = d end 178 if not p.unlisted then
179 local d = p.depth + 1
180 if d > depth then depth = d end
181 end
182 end
175 end 183 end
176 184
177 return depth 185 meta.depth = depth
186
187 return meta
178end 188end
179 189
180function d1_page_to_list_item(meta, p) 190function d1_page_to_list_item(meta, p)
@@ -314,7 +324,6 @@ function process(global, meta)
314 end 324 end
315 325
316 meta.pages = process_pages(global, meta.list_order, meta.pages) 326 meta.pages = process_pages(global, meta.list_order, meta.pages)
317 meta.depth = meta.depth and tonumber(pandoc.utils.stringify(meta.depth)) or find_depth(meta.pages)
318 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth)) 327 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth))
319 328
320 if meta.last_update then 329 if meta.last_update then
@@ -339,5 +348,6 @@ end
339function Meta(meta) 348function Meta(meta)
340 meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") 349 meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "")
341 350
351 find_depth(meta)
342 return process(meta, meta) 352 return process(meta, meta)
343end 353end