From 72f5e498831aa370ef2ce46745bc63397b5c9213 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 8 May 2018 02:46:29 +0100 Subject: [PATCH] lib/lua/nb.lua --- lib/lua/nb.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 -- 2.47.3