summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/notebook/pages/index.md1
-rw-r--r--scripts/metadata.lua35
-rw-r--r--templates/feed.xml22
3 files changed, 24 insertions, 34 deletions
diff --git a/content/notebook/pages/index.md b/content/notebook/pages/index.md
index b32e28a..1c8fbc5 100644
--- a/content/notebook/pages/index.md
+++ b/content/notebook/pages/index.md
@@ -1,5 +1,6 @@
1--- 1---
2title: Pages 2title: Pages
3depth: 1
3position: 1 4position: 1
4list_read_indicators: true 5list_read_indicators: true
5feed: true 6feed: true
diff --git a/scripts/metadata.lua b/scripts/metadata.lua
index 98ad9e5..9cb9970 100644
--- a/scripts/metadata.lua
+++ b/scripts/metadata.lua
@@ -162,9 +162,7 @@ function process_pages(global, order, pages_by_id)
162 pages_date_desc:sort(page_sort("date_desc")) 162 pages_date_desc:sort(page_sort("date_desc"))
163 end 163 end
164 164
165 local pages_data = { 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 }
166
167 return pages_data
168end 166end
169 167
170function find_depth(pages) 168function find_depth(pages)
@@ -240,21 +238,17 @@ function cat_to_list_cat(cat, allItems)
240 } 238 }
241end 239end
242 240
243function generate_list(global, meta) 241function generate_list(meta)
244 if meta.depth < 1 then return nil end 242 if meta.depth < 1 then return nil end
245 243
246 if meta.depth == 1 then 244 if meta.depth == 1 then
247 return meta.pages.all 245 return meta.pages.all:map(function(p) return d1_page_to_list_item(meta, p) end)
248 :map(function(p) return d1_page_to_list_item(meta, p) end)
249 :filter(function(p) return not p.draft or global.mode == "dev" end)
250 end 246 end
251 247
252 if meta.depth == 2 then 248 if meta.depth == 2 then
253 return meta.pages.all 249 return meta.pages.all
254 :map(function(cat) 250 :map(function(cat)
255 local allItems = cat.pages.all 251 local allItems = cat.pages.all:map(function(p) return d2_page_to_list_item(meta, cat, p, false) end)
256 :map(function(p) return d2_page_to_list_item(meta, cat, p, false) end)
257 :filter(function(p) return not p.draft or global.mode == "dev" end)
258 252
259 return cat_to_list_cat(cat, allItems) 253 return cat_to_list_cat(cat, allItems)
260 end) 254 end)
@@ -264,15 +258,13 @@ function generate_list(global, meta)
264 if meta.depth == 3 then 258 if meta.depth == 3 then
265 local list = meta.pages.all 259 local list = meta.pages.all
266 :map(function(cat) 260 :map(function(cat)
267 local allItems = cat.pages.all 261 local allItems = cat.pages.all:flatMap(function(c)
268 :flatMap(function(c) 262 if cat.list_flatten and c.depth ~= 0 then
269 if #c.pages.all ~= 0 and cat.list_flatten then 263 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end)
270 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) 264 else
271 else 265 return pandoc.List({ d1_page_to_list_item(cat, c) })
272 return pandoc.List({ d1_page_to_list_item(cat, c) }) 266 end
273 end 267 end)
274 end)
275 :filter(function(p) return not p.draft or global.mode == "dev" end)
276 268
277 allItems:sort(page_sort(cat.list_order)) 269 allItems:sort(page_sort(cat.list_order))
278 270
@@ -287,6 +279,7 @@ end
287function process(global, meta) 279function process(global, meta)
288 meta.namespace = resolve_namespace(meta.namespace) 280 meta.namespace = resolve_namespace(meta.namespace)
289 meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "") 281 meta.file_out = pandoc.utils.stringify(meta.file_out):gsub("^out", "")
282 meta.unlisted = meta.unlisted or (meta.draft and global.mode ~= "dev")
290 meta.redirect = meta.url and true 283 meta.redirect = meta.url and true
291 meta.url = meta.url and pandoc.utils.stringify(meta.url) 284 meta.url = meta.url and pandoc.utils.stringify(meta.url)
292 meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out) 285 meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out)
@@ -321,7 +314,7 @@ function process(global, meta)
321 end 314 end
322 315
323 meta.pages = process_pages(global, meta.list_order, meta.pages) 316 meta.pages = process_pages(global, meta.list_order, meta.pages)
324 meta.depth = find_depth(meta.pages) 317 meta.depth = meta.depth and tonumber(pandoc.utils.stringify(meta.depth)) or find_depth(meta.pages)
325 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth)) 318 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth))
326 319
327 if meta.last_update then 320 if meta.last_update then
@@ -338,7 +331,7 @@ function process(global, meta)
338 meta.date = meta.last_update 331 meta.date = meta.last_update
339 end 332 end
340 333
341 meta.list = generate_list(global, meta) 334 meta.list = generate_list(meta)
342 335
343 return meta 336 return meta
344end 337end
diff --git a/templates/feed.xml b/templates/feed.xml
index e6d3cae..915c000 100644
--- a/templates/feed.xml
+++ b/templates/feed.xml
@@ -17,24 +17,20 @@
17 $if(layout.is_categorized_list)$ 17 $if(layout.is_categorized_list)$
18 $for(pages.date_desc)$ 18 $for(pages.date_desc)$
19 $for(it.pages.date_desc)$ 19 $for(it.pages.date_desc)$
20 $if(it.draft)$$else$
21 $if(it.url)$
22 <entry>
23 <category term="$pages.date_desc.namespace.full$" label="$pages.date_desc.title$"/>
24 $it:feed_entry()$
25 </entry>
26 $endif$
27 $endif$
28 $endfor$
29 $endfor$
30 $else$
31 $for(pages.date_desc)$
32 $if(it.draft)$$else$
33 $if(it.url)$ 20 $if(it.url)$
34 <entry> 21 <entry>
22 <category term="$pages.date_desc.namespace.full$" label="$pages.date_desc.title$"/>
35 $it:feed_entry()$ 23 $it:feed_entry()$
36 </entry> 24 </entry>
37 $endif$ 25 $endif$
26 $endfor$
27 $endfor$
28 $else$
29 $for(pages.date_desc)$
30 $if(it.url)$
31 <entry>
32 $it:feed_entry()$
33 </entry>
38 $endif$ 34 $endif$
39 $endfor$ 35 $endfor$
40 $endif$ 36 $endif$