local vars = {}
-- Extract title from content or filename or dirname
- vars.title = string.match(content,'^#[\t ]*([^\r\n]+)')
+ --vars.title = string.match(content,'^#[\t ]*([^\r\n]+)')
+-- if not vars.title then
+-- vars.title = string.match(file,'([^/%.]+)%.') -- basename
+-- if vars.title == 'index' then
+-- vars.title = string.match(file,'/([^/]+)/[^/]+$')
+-- end
+-- end
if not vars.title then
- vars.title = string.match(file,'([^/%.]+)%.')
- if vars.title == 'index' then
- vars.title = string.match(file,'/([^/]+)/[^/]+$')
+ local basename = string.match(ngx.var.request_uri,'([^/]+)$')
+ if basename then
+ local noext = string.match(basename,'([^%.]+)')
+ vars.title = noext
end
end
+ if not vars.title then vars.title = string.match(ngx.var.http_host,'^([^%.]+)') end
local header = nb:readall(ngx.var.document_root .. "/header.html")
if header then template.render(header,vars) end