mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791
This commit is contained in:
parent
ae7eaebf9e
commit
1a991bf20f
3 changed files with 8 additions and 11 deletions
|
|
@ -455,10 +455,9 @@ func getRefIDsByFileAnnotationID(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
refIDs, refTexts := model.GetBlockRefIDsByFileAnnotationID(id)
|
refIDs := model.GetBlockRefIDsByFileAnnotationID(id)
|
||||||
ret.Data = map[string][]string{
|
ret.Data = map[string][]string{
|
||||||
"refIDs": refIDs,
|
"refIDs": refIDs,
|
||||||
"refTexts": refTexts,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,9 +369,8 @@ func queryDocRefDefs(rootID string) (refDefs []*RefDefs) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBlockRefIDsByFileAnnotationID(id string) (refIDs, refTexts []string) {
|
func GetBlockRefIDsByFileAnnotationID(id string) []string {
|
||||||
refIDs, refTexts = sql.QueryRefIDsByAnnotationID(id)
|
return sql.QueryRefIDsByAnnotationID(id)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBlockDefIDsByRefText(refText string, excludeIDs []string) (ret []string) {
|
func GetBlockDefIDsByRefText(refText string, excludeIDs []string) (ret []string) {
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,21 @@ type FileAnnotationRef struct {
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
|
||||||
func QueryRefIDsByAnnotationID(annotationID string) (refIDs, refTexts []string) {
|
func QueryRefIDsByAnnotationID(annotationID string) (refIDs []string) {
|
||||||
refIDs = []string{}
|
refIDs = []string{}
|
||||||
rows, err := query("SELECT block_id, content FROM file_annotation_refs WHERE annotation_id = ?", annotationID)
|
rows, err := query("SELECT block_id FROM file_annotation_refs WHERE annotation_id = ?", annotationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.LogErrorf("sql query failed: %s", err)
|
logging.LogErrorf("sql query failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id, content string
|
var id string
|
||||||
if err = rows.Scan(&id, &content); err != nil {
|
if err = rows.Scan(&id); err != nil {
|
||||||
logging.LogErrorf("query scan field failed: %s", err)
|
logging.LogErrorf("query scan field failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
refIDs = append(refIDs, id)
|
refIDs = append(refIDs, id)
|
||||||
refTexts = append(refTexts, content)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue