🎨 Add the custom-dailynote-yyyyMMdd attribute when creating a dailynote doc https://github.com/siyuan-note/siyuan/issues/9807

This commit is contained in:
Daniel 2023-12-04 17:53:04 +08:00
parent 0d9b8feeda
commit 2ba42bb398
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1076,6 +1076,20 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
if nil != existRoot {
existed = true
p = existRoot.Path
tree, loadErr := loadTreeByBlockID(existRoot.RootID)
if nil != loadErr {
logging.LogWarnf("load tree by block id [%s] failed: %v", existRoot.RootID, loadErr)
return
}
p = tree.Path
date := time.Now().Format("20060102")
if tree.Root.IALAttr("custom-dailynote-"+date) == "" {
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
if err = indexWriteJSONQueue(tree); nil != err {
return
}
}
return
}
@ -1127,8 +1141,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
return
}
p = tree.Path
date := util.TimeFromID(id)
date = date[:len("yyyyMMdd")]
date := time.Now().Format("20060102")
tree.Root.SetIALAttr("custom-dailynote-"+date, date)
if err = indexWriteJSONQueue(tree); nil != err {
return