Skip to content

Commit

Permalink
use sidebarTocNode / sidebarTocContent instead of sidebarTocTree
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 15, 2023
1 parent 3af994b commit 5693007
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/markup/markdown/convertyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func nodeToTable(meta *yaml.Node) ast.Node {

func mappingNodeToTable(meta *yaml.Node) ast.Node {
table := east.NewTable()
var alignments := make([]east.Alignment, 0, len(meta.Content)/2)
alignments := make([]east.Alignment, 0, len(meta.Content)/2)
for i := 0; i < len(meta.Content); i += 2 {
alignments = append(alignments, east.AlignNone)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/markup/markdown/goldmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
node.InsertBefore(node, firstChild, tocNode)
} else {
tocNode := createTOCNode(tocList, rc.Lang, map[string]string{"open": "open"})
ctx.SidebarTocTree = tocNode
ctx.SidebarTocNode = tocNode
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/markup/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type RenderContext struct {
GitRepo *git.Repository
ShaExistCache map[string]bool
cancelFn func()
SidebarTocTree ast.Node
SidebarTocNode ast.Node
RenderMetaAs RenderMetaMode
InStandalonePage bool // used by external render. the router "/org/repo/render/..." will output the rendered content in a standalone page
}
Expand Down
6 changes: 3 additions & 3 deletions routers/web/repo/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
ctx.Data["footerPresent"] = false
}

if rctx.SidebarTocTree != nil {
if rctx.SidebarTocNode != nil {
sb := &strings.Builder{}
err = markdown.SpecializedMarkdown().Renderer().Render(sb, nil, rctx.SidebarTocTree)
err = markdown.SpecializedMarkdown().Renderer().Render(sb, nil, rctx.SidebarTocNode)
if err != nil {
log.Error("Failed to render wiki sidebar TOC: %v", err)
} else {
ctx.Data["sidebarTocTree"] = sb.String()
ctx.Data["sidebarTocContent"] = sb.String()
}
}

Expand Down
10 changes: 5 additions & 5 deletions templates/repo/wiki/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
<p>{{.FormatWarning}}</p>
</div>
{{end}}
<div class="ui gt-mt-0 {{if or .sidebarPresent .sidebarTocTree}}grid equal width{{end}}">
<div class="ui {{if or .sidebarPresent .sidebarTocTree}}eleven wide column{{else}}gt-ml-0{{end}} segment markup wiki-content-main">
<div class="ui gt-mt-0 {{if or .sidebarPresent .sidebarTocContent}}grid equal width{{end}}">
<div class="ui {{if or .sidebarPresent .sidebarTocContent}}eleven wide column{{else}}gt-ml-0{{end}} segment markup wiki-content-main">
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
{{.content | Safe}}
</div>
{{if or .sidebarPresent .sidebarTocTree}}
{{if or .sidebarPresent .sidebarTocContent}}
<div class="column gt-pt-0">
{{if .sidebarTocTree}}
{{if .sidebarTocContent}}
<div class="ui segment wiki-content-toc">
{{.sidebarTocTree | Safe}}
{{.sidebarTocContent | Safe}}
</div>
{{end}}
{{if .sidebarPresent}}
Expand Down

0 comments on commit 5693007

Please sign in to comment.