added: url param to create note with tags
This commit is contained in:
parent
ca73d0fcff
commit
e2a8529e93
9
main.js
9
main.js
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue