Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-03-22 23:09:27 +08:00
commit 983b0317ef
2 changed files with 11 additions and 1 deletions

View file

@ -1129,7 +1129,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
// Creating a dailynote template supports doc attributes https://github.com/siyuan-note/siyuan/issues/10698
templateIALs := parse.IAL2Map(templateTree.Root.KramdownIAL)
for k, v := range templateIALs {
if "name" == k || "alias" == k || "bookmark" == k || "memo" == k || "title" == k || strings.HasPrefix(k, "custom-") {
if "name" == k || "alias" == k || "bookmark" == k || "memo" == k || strings.HasPrefix(k, "custom-") {
tree.Root.SetIALAttr(k, v)
}
}

View file

@ -169,6 +169,16 @@ func DocSaveAsTemplate(id, name string, overwrite bool) (code int, err error) {
luteEngine := NewLute()
formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions)
md := formatRenderer.Render()
// 单独渲染根节点的 IAL
if 0 < len(tree.Root.KramdownIAL) {
// 把 docIAL 中的 id 调整到第一个
tree.Root.RemoveIALAttr("id")
tree.Root.KramdownIAL = append([][]string{{"id", tree.Root.ID}}, tree.Root.KramdownIAL...)
md = append(md, []byte("\n")...)
md = append(md, parse.IAL2Tokens(tree.Root.KramdownIAL)...)
}
name = util.FilterFileName(name) + ".md"
name = util.TruncateLenFileName(name)
savePath := filepath.Join(util.DataDir, "templates", name)