From a5b53c0dde1ea07986d9d16dfe863249b1ff8ac0 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 4 Nov 2024 16:54:38 +0800 Subject: [PATCH] :art: Improve the backlink panel breadcrumb and block sorting https://github.com/siyuan-note/siyuan/issues/13008 --- kernel/model/backlink.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 310617a22..88c16e349 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -109,6 +109,7 @@ func GetBackmentionDoc(defID, refTreeID, keyword string, containChildren bool) ( if 0 < len(trees) { sortBacklinks(ret, refTree) + filterBlockPaths(ret) } return } @@ -151,6 +152,7 @@ func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren bool) (ret } sortBacklinks(ret, refTree) + filterBlockPaths(ret) for i := len(ret) - 1; 0 < i; i-- { curPaths := ret[i].BlockPaths @@ -163,6 +165,16 @@ func GetBacklinkDoc(defID, refTreeID, keyword string, containChildren bool) (ret return } +func filterBlockPaths(blockLinks []*Backlink) { + for _, b := range blockLinks { + if 1 == len(b.BlockPaths) && "NodeDocument" == b.BlockPaths[0].Type { + // 如果只有根文档这一层则不显示 + b.BlockPaths = []*BlockPath{} + } + } + return +} + func blockPathsEqual(paths1, paths2 []*BlockPath) bool { if len(paths1) != len(paths2) { return false