refactor: remove deprecated SidebarTocNode and clean up sidebar TOC rendering

- Eliminate the deprecated SidebarTocNode from RenderContext and related functions.
- Update sidebar TOC rendering logic to exclusively use SidebarTocHeaders for improved clarity and maintainability.
- Remove fallback logic for legacy TOC rendering to streamline the codebase.
This commit is contained in:
hamki committed 2026-01-26 16:52:57 +08:00
1 parent 4f3d5f2968
commit a9d4df6bb3
1 file changed
+1 -12
+1 -12
View File
@@ -35,7 +35,6 @@ import (
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/templates"
@@ -176,20 +175,10 @@ func markupRenderToHTML(ctx *context.Context, renderCtx *markup.RenderContext, r
}
func renderSidebarTocHTML(rctx *markup.RenderContext, lang string) template.HTML {
// Prefer the new generic SidebarTocHeaders
if len(rctx.SidebarTocHeaders) > 0 {
return markup.RenderSidebarTocHTML(rctx.SidebarTocHeaders, lang)
}
// Fallback to legacy SidebarTocNode for backward compatibility
if rctx.SidebarTocNode == nil {
return ""
}
sb := &strings.Builder{}
if err := markdown.SpecializedMarkdown(rctx).Renderer().Render(sb, nil, rctx.SidebarTocNode); err != nil {
log.Error("Failed to render sidebar TOC: %v", err)
return ""
}
return templates.SanitizeHTML(sb.String())
return ""
}
func checkHomeCodeViewable(ctx *context.Context) {