added: url param to create note with tags

This commit is contained in:
quenousimporte 2023-09-21 22:16:12 +02:00
parent ca73d0fcff
commit e2a8529e93
1 changed files with 5 additions and 4 deletions

View File

@ -1176,6 +1176,7 @@ function loadstorage()
var params = new URLSearchParams(window.location.search); var params = new URLSearchParams(window.location.search);
var title = params.get("n"); var title = params.get("n");
var line = params.get("l"); var line = params.get("l");
var tags = params.get("t");
if (currentnote) if (currentnote)
{ {
@ -1186,7 +1187,7 @@ function loadstorage()
currentnote = getnote(title); currentnote = getnote(title);
if (!currentnote) if (!currentnote)
{ {
currentnote = {title: title, content: ""}; currentnote = {title: title, content: defaultheaders(title, tags)};
localdata.unshift(currentnote); localdata.unshift(currentnote);
} }
} }
@ -2201,7 +2202,7 @@ function insertheader()
{ {
if (preview.hidden && !md.value.startsWith("---\n")) if (preview.hidden && !md.value.startsWith("---\n"))
{ {
var headers = "---\ndate: " + (new Date).toISOString().substring(0, 10) + "\ntags: \n---\n\n"; var headers = defaultheaders(currentnote.title);
md.value = headers + md.value; md.value = headers + md.value;
setpos(27); setpos(27);
} }
@ -2544,13 +2545,13 @@ function bindfile(note)
setpos(note.pos || 0); setpos(note.pos || 0);
} }
function defaultheaders(title) function defaultheaders(title, tags = "")
{ {
return [ return [
"---", "---",
"title: " + title, "title: " + title,
"date: " + timestamp().substr(0,10), "date: " + timestamp().substr(0,10),
"tags: ", "tags: " + (tags || ""),
"---", "---",
"",""].join("\n"); "",""].join("\n");
} }