local content = self:readall(file)
local vars = self:ngx_vars()
+ -- Extract title from content or filename or dirname
vars.title = string.match(content,'^#[\t ]*([^\r\n]+)')
- -- if not vars.title then vars.title = string.match(file,'([^\.]+)\.') end
+ if not vars.title then
+ vars.title = string.match(file,'([^/%.]+)%.')
+ if vars.title == 'index' then
+ vars.title = string.match(file,'/([^/]+)/[^/]+$')
+ end
+ end
local head = nb:readall(ngx.var.document_root .. "/head.html")
if head then template.render(head,vars) end
- template.render("{*markdown[[" .. content .. " ]]*}",vars)
+ if string.match(file,'%.md$') then
+ -- First replace tags then md render
+ content = template.output(template.compile(content)(vars))
+ template.render("{*markdown[[" .. content .. "]]*}",vars)
+ end
local tail = nb:readall(ngx.var.document_root .. "/tail.html")
if tail then template.render(tail,vars) end
geoip_postal_code = ngx.var.geoip_postal_code,
geoip_latitude = ngx.var.geoip_latitude,
geoip_longitude = ngx.var.geoip_longitude,
+ remote_addr = ngx.var.remote_addr,
+ http_user_agent = ngx.var.http_user_agent,
}
return vars
end