Add function to open root index file
Call up `require 'zettelkasten'.open_index()` to open the file.
Pass along a file name `require 'zettelkasten'.open_index('home')` to
open said file at the zettel root instead.
This commit is contained in:
parent
98eeaf6fc7
commit
aad77cff07
3 changed files with 45 additions and 8 deletions
|
|
@ -52,4 +52,19 @@ function A.make_link(visual)
|
|||
start_col))
|
||||
end
|
||||
|
||||
return {open = A.open, open_selected = A.open_selected, make_link = A.make_link}
|
||||
-- Opens an index.md file at the zettelkasten root directory whether it
|
||||
-- exists or not.
|
||||
function A.open_index_file(name)
|
||||
local link = {
|
||||
ref = o.zettel().rootdir .. "/" .. (name or "index") ..
|
||||
o.zettel().extension
|
||||
}
|
||||
A.open(link)
|
||||
end
|
||||
|
||||
return {
|
||||
open = A.open,
|
||||
open_selected = A.open_selected,
|
||||
open_index_file = A.open_index_file,
|
||||
make_link = A.make_link
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,15 @@ function ZK.open_or_make_link(visual)
|
|||
if not ZK.open_link() then ZK.make_link(visual) end
|
||||
end
|
||||
|
||||
-- Open index file at zettel root directory. If title is passed in opens
|
||||
-- `title`.<extension> file, otherwise defaults to `index`.<extension>.
|
||||
function ZK.open_index(title) return action.open_index_file(title) end
|
||||
|
||||
return {
|
||||
get_zettel_list = ZK.get_zettel_list,
|
||||
get_anchor = ZK.get_anchor,
|
||||
open_link = ZK.open_link,
|
||||
make_link = ZK.make_link,
|
||||
open_or_make_link = ZK.open_or_make_link
|
||||
open_or_make_link = ZK.open_or_make_link,
|
||||
open_index = ZK.open_index
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue