Skip to content

Commit c4a775e

Browse files
author
neo451
committed
remove more title usage
1 parent 6abf7bc commit c4a775e

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

lua/obsidian/commands/extract_note.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ return function(data)
1616
local content = vim.split(viz.selection, "\n", { plain = true })
1717

1818
---@type string|?
19-
local title
19+
local id
2020
if data.args ~= nil and string.len(data.args) > 0 then
21-
title = vim.trim(data.args)
21+
id = vim.trim(data.args)
2222
else
23-
title = api.input "Enter title (optional): "
24-
if not title then
23+
id = api.input "Enter title (optional): "
24+
if not id then
2525
log.warn "Aborted"
2626
return
27-
elseif title == "" then
28-
title = nil
27+
elseif id == "" then
28+
id = nil
2929
end
3030
end
3131

3232
-- create the new note.
33-
local note = Note.create { title = title }
33+
local note = Note.create { id = id }
3434

3535
-- replace selection with link to new note
3636
local link = note:format_link()

lua/obsidian/commands/link_new.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ return function(data)
1515

1616
local line = assert(viz.lines[1], "invalid visual selection")
1717

18-
local title
18+
local id
1919
if string.len(data.args) > 0 then
20-
title = data.args
20+
id = data.args
2121
else
22-
title = viz.selection
22+
id = viz.selection
2323
end
2424

25-
local note = Note.create { title = title }
25+
local note = Note.create { id = id }
2626

2727
local new_line = string.sub(line, 1, viz.cscol - 1)
28-
.. note:format_link { label = title }
28+
.. note:format_link { label = id }
2929
.. string.sub(line, viz.cecol + 1)
3030

3131
vim.api.nvim_buf_set_lines(0, viz.csrow - 1, viz.csrow, false, { new_line })

lua/obsidian/commands/new_from_template.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ return function(data)
1717
end
1818

1919
---@type string?
20-
local title = table.concat(data.fargs, " ", 1, #data.fargs - 1)
20+
local id = table.concat(data.fargs, " ", 1, #data.fargs - 1)
2121
local template = data.fargs[#data.fargs]
2222

23-
if title ~= nil and template ~= nil then
24-
local note = Note.create { title = title, template = template, should_write = true }
23+
if id ~= nil and template ~= nil then
24+
local note = Note.create { id = id, template = template, should_write = true }
2525
note:open { sync = true }
2626
return
2727
end
@@ -31,16 +31,16 @@ return function(data)
3131
dir = templates_dir,
3232
no_default_mappings = true,
3333
callback = function(template_name)
34-
if title == nil or title == "" then
34+
if id == nil or id == "" then
3535
-- Must use pcall in case of KeyboardInterrupt
3636
-- We cannot place `title` where `safe_title` is because it would be redeclaring it
3737
local success, safe_title = pcall(util.input, "Enter title or path (optional): ", { completion = "file" })
38-
title = safe_title
38+
id = safe_title
3939
if not success or not safe_title then
4040
log.warn "Aborted"
4141
return
4242
elseif safe_title == "" then
43-
title = nil
43+
id = nil
4444
end
4545
end
4646

@@ -50,7 +50,7 @@ return function(data)
5050
end
5151

5252
---@type obsidian.Note
53-
local note = Note.create { title = title, template = template_name, should_write = true }
53+
local note = Note.create { id = id, template = template_name, should_write = true }
5454
note:open { sync = false }
5555
end,
5656
}

lua/obsidian/note.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,6 @@ end
11491149
---@field new_notes_location string
11501150

11511151
---@class obsidian.note.NoteOpts
1152-
---@field title string|? The note's title
11531152
---@field id string|? An ID to assign the note. If not specified one will be generated.
11541153
---@field dir string|obsidian.Path|? An optional directory to place the note in. Relative paths will be interpreted
11551154
---relative to the workspace / vault root. If the directory doesn't exist it will

0 commit comments

Comments
 (0)