@@ -200,7 +200,12 @@ func (m *Document) ReleaseContent(bookId int, baseUrl string) {
200200 beego .Error (err )
201201 continue
202202 }
203- if len (utils .GetTextFromHtml (ds .Content )) == 0 {
203+
204+ if strings .TrimSpace (utils .GetTextFromHtml (strings .Replace (ds .Markdown , "[TOC]" , "" , - 1 ))) == "" {
205+ // 如果markdown内容为空,则查询下一级目录内容来填充
206+ ds .Markdown , ds .Content = item .BookStackAuto (bookId , ds .DocumentId )
207+ ds .Markdown = "[TOC]\n \n " + ds .Markdown
208+ } else if len (utils .GetTextFromHtml (ds .Content )) == 0 {
204209 //内容为空,渲染一下文档,然后再重新获取
205210 utils .RenderDocumentById (item .DocumentId )
206211 ds , _ = ModelStore .GetById (item .DocumentId )
@@ -551,7 +556,7 @@ func (m *Document) BookStackAuto(bookId, docId int) (md, cont string) {
551556 var newMd []string //新markdown内容
552557 for _ , doc := range docs {
553558 newMd = append (newMd , fmt .Sprintf (`- [%v]($%v)` , doc .DocumentName , doc .Identify ))
554- newCont = append (newCont , fmt .Sprintf (`<li><a href="$ %v">%v</a></li>` , doc .Identify , doc .DocumentName ))
559+ newCont = append (newCont , fmt .Sprintf (`<li><a href="%v">%v</a></li>` , doc .Identify , doc .DocumentName ))
555560 }
556561 md = strings .Join (newMd , "\n " )
557562 cont = "<ul>" + strings .Join (newCont , "" ) + "</ul>"
0 commit comments