0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-09 08:45:45 +02:00

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 2026-01-18 14:58:37 +08:00
parent 4f3d5f2968
commit a9d4df6bb3
No known key found for this signature in database
GPG Key ID: 092D4EC7F4DECB68

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) {