objectDecorators:
- where: 'tag = "page" and name = "index"'
attributes:
pageDecoration.disableTOC: true
- where: 'tag = "page" and tags = "house"'
attributes:
pageDecoration.prefix: "'🏠'"
- where: 'tag = "page" and (tags = "music" or tags = "make-music")'
attributes:
pageDecoration.prefix: "'🎵'"
- where: 'tag = "page" and name =~ "^People/"'
attributes:
pageDecoration.prefix: "'👤'"
This seems like a good candidate for Lua-fication, replacing the query language. However, this does affect the index (because it’s rendered onto links into the page), so perhaps not that straightforward?
Yes, this is on my list to add back in a more Lua native way. What I planned was to have a way to configure Lua metatables to use for tags.
Conceptually:
index.defineTagMetaTable("page", {
__index = function(self, attr)
if attr == "pageDecoration" and self.name == "index" then
return {disableTOC=true}
end
end
})
Then, whenever you query with index.tag "page" the objects it return would have the right metatables set, and then when requesting the pageDecoration attribute, it would calculate this value on the fly.
I still do not understand why the TOC cannot be generated by Lua function and hooked to the top of the page (or called like ${toc(3)} for example)? There is support to get the AST of the page so it’s just about traversing it and fetching headings leafs… which seems fairly easy to implement in Lua and add to the libraries with some pre-defined hook for the top to use it…