Skip to content

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

:art: Display document title in data history preview area https://github.com/siyuan-note/siyuan/issues/12948

Daniela15899d4211a
diff --git a/kernel/api/repo.go b/kernel/api/repo.go
index 14cb0e34f4..f0b917e85d 100644
--- a/kernel/api/repo.go
+++ b/kernel/api/repo.go
@@ -70,7 +70,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
}
id := arg["id"].(string)
- content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
+ title, content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
@@ -78,6 +78,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
}
ret.Data = map[string]interface{}{
+ "title": title,
"content": content,
"isProtyleDoc": isProtyleDoc,
"updated": updated,
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index a11249a779..86e916e172 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -79,7 +79,7 @@ func GetRepoFile(fileID string) (ret []byte, p string, err error) {
return
}
-func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) {
+func OpenRepoSnapshotDoc(fileID string) (title, content string, isProtyleDoc bool, updated int64, err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
return
@@ -110,6 +110,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
return
}
+ title = snapshotTree.Root.IALAttr("title")
if !isProtyleDoc {
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
@@ -150,6 +151,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
}
} else {
isProtyleDoc = true
+ title = path.Base(file.Path)
if strings.HasSuffix(file.Path, ".json") {
content = gulu.Str.FromBytes(data)
} else {