summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata_filter.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 413ded5..4ac4a4d 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -19,6 +19,10 @@ function pandoc.List:take(n)
19 return result 19 return result
20end 20end
21 21
22function slug(str)
23 return str:lower():gsub("[^ a-z]", ""):gsub("[ ]+", "-")
24end
25
22function file_exists(name) 26function file_exists(name)
23 local f = io.open(name, "r") 27 local f = io.open(name, "r")
24 if f ~= nil then 28 if f ~= nil then
@@ -196,6 +200,7 @@ function generate_list(meta)
196 subtitle = p.subtitle, 200 subtitle = p.subtitle,
197 date = p.date, 201 date = p.date,
198 url = p.url, 202 url = p.url,
203 slug = p.slug,
199 thumbnail = p.thumbnail, 204 thumbnail = p.thumbnail,
200 icon = p.icon or meta.icon, 205 icon = p.icon or meta.icon,
201 post_icon = p.post_icon or meta.list_post_icon, 206 post_icon = p.post_icon or meta.list_post_icon,
@@ -205,13 +210,14 @@ function generate_list(meta)
205 elseif meta.depth == "2" then 210 elseif meta.depth == "2" then
206 return meta.pages.all:map(function(cat) 211 return meta.pages.all:map(function(cat)
207 local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or 212 local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or
208 9999 213 9999
209 local allItems = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p) 214 local allItems = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p)
210 return { 215 return {
211 title = p.title, 216 title = p.title,
212 subtitle = p.subtitle, 217 subtitle = p.subtitle,
213 date = p.date, 218 date = p.date,
214 url = p.url, 219 url = p.url,
220 slug = p.slug,
215 thumbnail = p.thumbnail, 221 thumbnail = p.thumbnail,
216 icon = p.icon or cat.icon, 222 icon = p.icon or cat.icon,
217 post_icon = p.post_icon or cat.list_post_icon or meta.list_post_icon, 223 post_icon = p.post_icon or cat.list_post_icon or meta.list_post_icon,
@@ -226,6 +232,7 @@ function generate_list(meta)
226 description = (cat.description and pandoc.MetaBlocks(pandoc.Para(cat.description))) or 232 description = (cat.description and pandoc.MetaBlocks(pandoc.Para(cat.description))) or
227 (not cat.no_description and cat.content), 233 (not cat.no_description and cat.content),
228 url = cat.url, 234 url = cat.url,
235 slug = cat.slug,
229 layout = cat.list_layout, 236 layout = cat.list_layout,
230 items = items, 237 items = items,
231 total = tostring(#allItems), 238 total = tostring(#allItems),
@@ -235,7 +242,7 @@ function generate_list(meta)
235 elseif meta.depth == "3" then 242 elseif meta.depth == "3" then
236 return meta.pages.all:map(function(cat) 243 return meta.pages.all:map(function(cat)
237 local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or 244 local limit = (cat.list_limit and tonumber(pandoc.utils.stringify(cat.list_limit))) or
238 9999 245 9999
239 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c) 246 local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c)
240 if c.pages then 247 if c.pages then
241 return c.pages.all:map(function(p) 248 return c.pages.all:map(function(p)
@@ -244,6 +251,7 @@ function generate_list(meta)
244 subtitle = p.subtitle, 251 subtitle = p.subtitle,
245 category = c.title, 252 category = c.title,
246 url = p.url, 253 url = p.url,
254 slug = p.slug,
247 thumbnail = p.thumbnail, 255 thumbnail = p.thumbnail,
248 icon = p.icon or c.icon, 256 icon = p.icon or c.icon,
249 post_icon = p.post_icon or c.list_post_icon or cat.list_post_icon, 257 post_icon = p.post_icon or c.list_post_icon or cat.list_post_icon,
@@ -256,6 +264,7 @@ function generate_list(meta)
256 title = c.title, 264 title = c.title,
257 subtitle = c.subtitle, 265 subtitle = c.subtitle,
258 url = c.url, 266 url = c.url,
267 slug = c.slug,
259 icon = c.icon or cat.icon, 268 icon = c.icon or cat.icon,
260 post_icon = c.post_icon or cat.list_post_icon, 269 post_icon = c.post_icon or cat.list_post_icon,
261 indicator = cat.list_read_indicators, 270 indicator = cat.list_read_indicators,
@@ -271,6 +280,7 @@ function generate_list(meta)
271 description = (cat.description and pandoc.MetaBlocks(pandoc.Para(cat.description))) or 280 description = (cat.description and pandoc.MetaBlocks(pandoc.Para(cat.description))) or
272 (not cat.no_description and cat.content), 281 (not cat.no_description and cat.content),
273 url = cat.url, 282 url = cat.url,
283 slug = cat.slug,
274 layout = cat.list_layout, 284 layout = cat.list_layout,
275 items = items, 285 items = items,
276 total = tostring(#allItems), 286 total = tostring(#allItems),
@@ -287,6 +297,7 @@ function process(global, meta)
287 meta.url = meta.url and pandoc.utils.stringify(meta.url) 297 meta.url = meta.url and pandoc.utils.stringify(meta.url)
288 meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out) 298 meta.url = resolve_url(global.site.url, global.file_out, meta.url or meta.file_out)
289 meta.title = (meta.title and pandoc.utils.stringify(meta.title)) or "" 299 meta.title = (meta.title and pandoc.utils.stringify(meta.title)) or ""
300 meta.slug = slug(meta.title)
290 if meta.list_order then meta.list_order = pandoc.utils.stringify(meta.list_order) end 301 if meta.list_order then meta.list_order = pandoc.utils.stringify(meta.list_order) end
291 meta.list_layout = meta.list_layout and prep_layout(meta.list_layout) 302 meta.list_layout = meta.list_layout and prep_layout(meta.list_layout)
292 if meta.position then meta.position = pandoc.utils.stringify(meta.position) end 303 if meta.position then meta.position = pandoc.utils.stringify(meta.position) end
@@ -318,7 +329,7 @@ function process(global, meta)
318 meta.pages = process_pages(global, meta.list_order, meta.pages) 329 meta.pages = process_pages(global, meta.list_order, meta.pages)
319 meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0" 330 meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0"
320 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or 331 meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or
321 resolve_layout(meta.depth)) 332 resolve_layout(meta.depth))
322 333
323 if meta.date then 334 if meta.date then
324 meta.date = format_date(meta.date) 335 meta.date = format_date(meta.date)