From ecf9d3a7d884d9b5e83b3323e54c2d7d2e45d8e9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 13 Jan 2025 12:26:19 +0800 Subject: [PATCH 1/2] :art: Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791 --- kernel/api/av.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/api/av.go b/kernel/api/av.go index 930f98302..66de4cbf7 100644 --- a/kernel/api/av.go +++ b/kernel/api/av.go @@ -72,7 +72,15 @@ func getMirrorDatabaseBlocks(c *gin.Context) { } avID := arg["avID"].(string) - ret.Data = treenode.GetMirrorAttrViewBlockIDs(avID) + blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID) + var retRefDefs []model.RefDefs + for _, blockID := range blockIDs { + retRefDefs = append(retRefDefs, model.RefDefs{RefID: blockID, DefIDs: []string{}}) + } + + ret.Data = map[string]any{ + "refDefs": retRefDefs, + } } func setDatabaseBlockView(c *gin.Context) { From 558e18f52fc9fdaa338061f63905bb7816aacf7c Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 13 Jan 2025 12:33:24 +0800 Subject: [PATCH 2/2] :art: Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791 --- kernel/api/block.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/api/block.go b/kernel/api/block.go index 70c87c13b..2e9328611 100644 --- a/kernel/api/block.go +++ b/kernel/api/block.go @@ -456,8 +456,13 @@ func getRefIDsByFileAnnotationID(c *gin.Context) { id := arg["id"].(string) refIDs := model.GetBlockRefIDsByFileAnnotationID(id) - ret.Data = map[string][]string{ - "refIDs": refIDs, + var retRefDefs []model.RefDefs + for _, blockID := range refIDs { + retRefDefs = append(retRefDefs, model.RefDefs{RefID: blockID, DefIDs: []string{}}) + } + + ret.Data = map[string]any{ + "refDefs": retRefDefs, } } @@ -478,7 +483,14 @@ func getBlockDefIDsByRefText(c *gin.Context) { } excludeIDs = nil // 不限制虚拟引用搜索自己 https://ld246.com/article/1633243424177 ids := model.GetBlockDefIDsByRefText(anchor, excludeIDs) - ret.Data = ids + var retRefDefs []model.RefDefs + for _, id := range ids { + retRefDefs = append(retRefDefs, model.RefDefs{RefID: id, DefIDs: []string{}}) + } + + ret.Data = map[string]any{ + "refDefs": retRefDefs, + } } func getBlockBreadcrumb(c *gin.Context) {