From e2a8529e93d3cba20a77165fcc1500d1cba18fcf Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 21 Sep 2023 22:16:12 +0200 Subject: [PATCH] added: url param to create note with tags --- main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 81ca64e..d736b6c 100644 --- a/main.js +++ b/main.js @@ -1176,6 +1176,7 @@ function loadstorage() var params = new URLSearchParams(window.location.search); var title = params.get("n"); var line = params.get("l"); + var tags = params.get("t"); if (currentnote) { @@ -1186,7 +1187,7 @@ function loadstorage() currentnote = getnote(title); if (!currentnote) { - currentnote = {title: title, content: ""}; + currentnote = {title: title, content: defaultheaders(title, tags)}; localdata.unshift(currentnote); } } @@ -2201,7 +2202,7 @@ function insertheader() { 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; setpos(27); } @@ -2544,13 +2545,13 @@ function bindfile(note) setpos(note.pos || 0); } -function defaultheaders(title) +function defaultheaders(title, tags = "") { return [ "---", "title: " + title, "date: " + timestamp().substr(0,10), - "tags: ", + "tags: " + (tags || ""), "---", "",""].join("\n"); }