Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Creating a dailynote template supports doc attributes https://github.com/siyuan-note/siyuan/issues/10698

Daniel8be272bfc6a1
diff --git a/kernel/model/template.go b/kernel/model/template.go
index bc71bb049e..909fb2eb9e 100644
--- a/kernel/model/template.go
+++ b/kernel/model/template.go
@@ -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)