This commit is contained in:
Liang Ding 2023-05-16 22:50:30 +08:00
parent a732e17190
commit c52da0c315
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -36,6 +36,7 @@ import (
type BlockInfo struct {
ID string `json:"id"`
RootID string `json:"rootID"`
Name string `json:"name"`
RefCount int `json:"refCount"`
SubFileCount int `json:"subFileCount"`
@ -44,17 +45,17 @@ type BlockInfo struct {
Icon string `json:"icon"`
}
func GetDocInfo(rootID string) (ret *BlockInfo) {
func GetDocInfo(blockID string) (ret *BlockInfo) {
WaitForWritingFiles()
tree, err := loadTreeByBlockID(rootID)
tree, err := loadTreeByBlockID(blockID)
if nil != err {
logging.LogErrorf("load tree by root id [%s] failed: %s", rootID, err)
logging.LogErrorf("load tree by root id [%s] failed: %s", blockID, err)
return
}
title := tree.Root.IALAttr("title")
ret = &BlockInfo{ID: rootID, Name: title}
ret = &BlockInfo{ID: blockID, RootID: tree.Root.ID, Name: title}
ret.IAL = parse.IAL2Map(tree.Root.KramdownIAL)
scrollData := ret.IAL["scroll"]
if 0 < len(scrollData) {
@ -81,7 +82,7 @@ func GetDocInfo(rootID string) (ret *BlockInfo) {
}
}
}
ret.RefIDs, _ = sql.QueryRefIDsByDefID(rootID, false)
ret.RefIDs, _ = sql.QueryRefIDsByDefID(blockID, false)
ret.RefCount = len(ret.RefIDs)
var subFileCount int