generate nav
This commit is contained in:
parent
68f533e6c3
commit
5190019fc3
|
@ -7,6 +7,7 @@ meta = {
|
|||
|
||||
webdir = "webtest" -- web output directory
|
||||
gemdir = "gemtest" -- gemini output directory
|
||||
-- TODO templates in spanish
|
||||
templates = {
|
||||
webEn = {
|
||||
header = { path = "pageheader.html", template = ""},
|
||||
|
@ -112,6 +113,8 @@ function firstPass()
|
|||
-- table to store the lines to write to file
|
||||
local lines = { web = {}, gem = {} }
|
||||
|
||||
local navlines = { "<ul>" }
|
||||
|
||||
-- convert one line at a time
|
||||
local count = 1
|
||||
for line in f:lines() do
|
||||
|
@ -159,9 +162,13 @@ function firstPass()
|
|||
out.web = closeTags()
|
||||
|
||||
elseif string.match( line, "^#+") then -- HEADERS
|
||||
-- TODO create nav
|
||||
local title, level = getHeader( line )
|
||||
|
||||
-- add h1 to navigation
|
||||
if level==1 then
|
||||
table.insert(navlines,string.format("<li><a href='#%s'>%s</a></li>",title,title))
|
||||
end
|
||||
|
||||
local close = closeTags()
|
||||
out.web = string.format("%s<h%d>%s</h%d>",close,level,title,level)
|
||||
|
||||
|
@ -260,6 +267,9 @@ function firstPass()
|
|||
table.insert( lines.web, close )
|
||||
end
|
||||
|
||||
table.insert( navlines, "</ul>" )
|
||||
pagemeta.navcontent = table.concat( navlines, "\n" )
|
||||
|
||||
-- set templates
|
||||
pagemeta.outs.web.templates = templates.webEn
|
||||
pagemeta.outs.gem.templates = templates.gemEn
|
||||
|
@ -483,6 +493,7 @@ local n = genIndex()
|
|||
-- converting from gmo to gmi and html and calculating incoming links
|
||||
print(string.format("convirtiendo %d páginas...",n))
|
||||
firstPass()
|
||||
|
||||
-- second pass, write incoming links
|
||||
print("escribiendo incoming links...")
|
||||
secondPass()
|
||||
|
|
Loading…
Reference in New Issue