fix #12 (working with subdirectories): links to notes within

sub-directories will now always contain the relative path
This commit is contained in:
Rene Schallner
2021-11-30 16:37:46 +01:00
parent e52c336391
commit 35f4e6342f

View File

@@ -220,12 +220,31 @@ local function create_note_from_template(title, filepath, templatefn, calendar_i
ofile:close() ofile:close()
end end
local function num_path_elems(p)
return #vim.split(p, "/")
end
local function path_to_linkname(p) local function path_to_linkname(p)
local fn = vim.split(p, "/") local ln
fn = fn[#fn]
fn = vim.split(fn, M.Cfg.extension) local special_dir = false
fn = fn[1] if num_path_elems(p:gsub(M.Cfg.dailies .. "/", "")) == 1 then
return fn ln = p:gsub(M.Cfg.dailies .. "/", "")
special_dir = true
end
if num_path_elems(p:gsub(M.Cfg.weeklies .. "/", "")) == 1 then
ln = p:gsub(M.Cfg.weeklies .. "/", "")
special_dir = true
end
if special_dir == false then
ln = p:gsub(M.Cfg.home .. "/", "")
end
local title = vim.split(ln, M.Cfg.extension)
title = title[1]
return title
end end
local function order_numeric(a, b) local function order_numeric(a, b)