Mercurial Hosting > luan
view website/src/lib/Shared.luan @ 1685:46cf5137cb6b
misc fixes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 08 Jun 2022 20:13:54 -0600 |
parents | 418b610e887b |
children | 2fbca5c84422 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local ipairs = Luan.ipairs or error() local pairs = Luan.pairs or error() local Shared = {} function Shared.head() %> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @import "/site.css"; </style> <% end local function header(crumbs) %> <div header> <a href="/">Luan</a> <% for _, crumb in ipairs(crumbs or {}) do %> / <%=crumb%> <% end %> </div> <% end Shared.header = header function Shared.docs_header() header{[[<a href="/docs.html">Documentation</a>]]} end local function show_toc(content) %> <ul> <% for id, info in pairs(content) do %> <li><a id="c_<%=id%>" href="#<%=id%>"><%=info.title%></a> <% local subs = info.subs if subs ~= nil then show_toc(subs) end %> </li> <% end %> </ul> <% end Shared.show_toc = show_toc local function nothing() end local function show_content(content,h) for id, info in pairs(content) do %> <div heading> <h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>> <a href="#c_<%=id%>">contents</a> </div> <% (info.content or nothing)() local subs = info.subs if subs ~= nil then show_content(subs,h+1) end end end Shared.show_content = show_content return Shared