added: default headers

This commit is contained in:
quenousimporte 2023-09-14 11:54:09 +02:00
parent 30f9f786c2
commit b1c687e9a5
1 changed files with 13 additions and 2 deletions

15
main.js
View File

@ -1347,7 +1347,7 @@ function getorcreate(title, content, putontop)
var note = getnote(title); var note = getnote(title);
if (!note) if (!note)
{ {
note = {title: title, content: content}; note = {title: title, content: content, pos: content.length};
localdata.push(note) localdata.push(note)
} }
@ -2487,9 +2487,20 @@ function bindfile(note)
setpos(note.pos || 0); setpos(note.pos || 0);
} }
function defaultheaders(title)
{
return [
"---",
"title: " + title,
"date: " + timestamp().substr(0,10),
"tags: ",
"---",
"",""].join("\n");
}
function loadnote(name) function loadnote(name)
{ {
var note = getorcreate(name, "", true); var note = getorcreate(name, defaultheaders(name), true);
bindfile(note); bindfile(note);
stat.cur.q = 0; stat.cur.q = 0;