1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 10:18:21 +01:00
antd-web-apps/doc/views/default/toc/index.ls
DanyLE a76942f2f3
All checks were successful
gitea-sync/antd-web-apps/pipeline/head This commit looks good
WIP: make code compatible with new SILK API
2023-04-26 18:51:03 +02:00

44 lines
1.2 KiB
Plaintext

<?lua
local gentree
gentree = function(data, controller, cpath)
if not data then
return ""
end
local caret = ''
if data.entries then
caret = '<span class = "caret"></span>'
end
local active = ""
local selected = ""
local highlight = ""
if data.tpath and cpath then
if cpath:match("^"..data.tpath) then
active = "active"
highlight = "class = 'highlight'"
end
if data.path == cpath then
selected = "class = 'selected'"
end
end
local markup = '<li '..selected..'>'..caret..'<a '..highlight..' href="'..HTTP_ROOT..'/'..controller..'/'..enc.b64encode(data.path):gsub("=","")..'/'..data.name:gsub(" ", "_")..'.md">'..data.name.."</a>"
if data.entries then
markup = markup.."<ul class='nested "..active.."'>"
for k,v in pairs(data.entries) do
markup = markup..gentree(v, controller, cpath)
end
markup = markup.."</ul>"
end
markup = markup.."</li>"
return markup
end
?>
<ul id = "toc">
<?lua
if data.error then
return echo("<li>Unable to read TOC</li>")
end
for k,v in pairs(data.data.entries) do
echo(gentree(v, data.controller, data.cpath))
end
?>
</ul>