mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
ab8b70d78d
commit
17595a3076
1 changed files with 18 additions and 4 deletions
|
|
@ -298,6 +298,8 @@ func buildBacklink(refID string, refTree *parse.Tree, luteEngine *lute.Lute) (re
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
|
func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int) {
|
||||||
|
keyword = strings.TrimSpace(keyword)
|
||||||
|
mentionKeyword = strings.TrimSpace(mentionKeyword)
|
||||||
backlinks, backmentions = []*Path{}, []*Path{}
|
backlinks, backmentions = []*Path{}, []*Path{}
|
||||||
|
|
||||||
sqlBlock := sql.GetBlock(id)
|
sqlBlock := sql.GetBlock(id)
|
||||||
|
|
@ -310,15 +312,27 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
|
||||||
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(id, refs)
|
linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(id, refs)
|
||||||
backlinks = toFlatTree(linkRefs, 0, "backlink")
|
tmpBacklinks := toFlatTree(linkRefs, 0, "backlink")
|
||||||
for _, l := range backlinks {
|
for _, l := range tmpBacklinks {
|
||||||
l.Blocks = nil
|
l.Blocks = nil
|
||||||
|
if "" != keyword {
|
||||||
|
if !strings.Contains(l.Name, keyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
backlinks = append(backlinks, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
mentionRefs := buildTreeBackmention(sqlBlock, linkRefs, mentionKeyword, excludeBacklinkIDs, beforeLen)
|
mentionRefs := buildTreeBackmention(sqlBlock, linkRefs, mentionKeyword, excludeBacklinkIDs, beforeLen)
|
||||||
backmentions = toFlatTree(mentionRefs, 0, "backlink")
|
tmpBackmentions := toFlatTree(mentionRefs, 0, "backlink")
|
||||||
for _, l := range backmentions {
|
for _, l := range tmpBackmentions {
|
||||||
l.Blocks = nil
|
l.Blocks = nil
|
||||||
|
if "" != mentionKeyword {
|
||||||
|
if !strings.Contains(l.Name, mentionKeyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
backmentions = append(backmentions, l)
|
||||||
}
|
}
|
||||||
mentionsCount = len(backmentions)
|
mentionsCount = len(backmentions)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue