mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 14:14:24 -05:00
fix #12 (working with subdirectories): links to notes within
sub-directories will now always contain the relative path
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user