mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Improve backlink filtering below the heading https://github.com/siyuan-note/siyuan/issues/14929
This commit is contained in:
parent
84e9a003e8
commit
c2c4c2393f
1 changed files with 32 additions and 0 deletions
|
|
@ -656,6 +656,38 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
|
|||
ret = append(ret, ref)
|
||||
}
|
||||
}
|
||||
|
||||
if 0 < len(keywords) {
|
||||
// 过滤场景处理标题下方块 Improve backlink filtering below the heading https://github.com/siyuan-note/siyuan/issues/14929
|
||||
headingRefChildren := map[string]*Block{}
|
||||
var headingIDs []string
|
||||
for _, link := range links {
|
||||
for _, ref := range link.Refs {
|
||||
if "NodeHeading" == ref.Type {
|
||||
headingRefChildren[ref.ID] = ref
|
||||
headingIDs = append(headingIDs, ref.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
var headingChildren []*Block
|
||||
for _, headingID := range headingIDs {
|
||||
sqlChildren := sql.GetChildBlocks(headingID, "", -1)
|
||||
children := fromSQLBlocks(&sqlChildren, "", 12)
|
||||
headingChildren = append(headingChildren, children...)
|
||||
}
|
||||
for _, child := range headingChildren {
|
||||
if nil == child {
|
||||
continue
|
||||
}
|
||||
|
||||
if matchBacklinkKeyword(child, keywords) {
|
||||
heading := headingRefChildren[child.ParentID]
|
||||
if nil != heading {
|
||||
ret = append(ret, heading)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue