From: Nicolas Boisselier Date: Tue, 8 May 2018 01:46:29 +0000 (+0100) Subject: lib/lua/nb.lua X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=72f5e498831aa370ef2ce46745bc63397b5c9213;p=nb.git lib/lua/nb.lua --- diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index ba5d0d53..ecdd745a 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -33,13 +33,21 @@ function nb:ngx_location_md() 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