mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-17 16:40:10 +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:
parent
4f3d5f2968
commit
a9d4df6bb3
@ -35,7 +35,6 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/lfs"
|
"code.gitea.io/gitea/modules/lfs"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/markup/markdown"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/structs"
|
"code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/templates"
|
"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 {
|
func renderSidebarTocHTML(rctx *markup.RenderContext, lang string) template.HTML {
|
||||||
// Prefer the new generic SidebarTocHeaders
|
|
||||||
if len(rctx.SidebarTocHeaders) > 0 {
|
if len(rctx.SidebarTocHeaders) > 0 {
|
||||||
return markup.RenderSidebarTocHTML(rctx.SidebarTocHeaders, lang)
|
return markup.RenderSidebarTocHTML(rctx.SidebarTocHeaders, lang)
|
||||||
}
|
}
|
||||||
// Fallback to legacy SidebarTocNode for backward compatibility
|
return ""
|
||||||
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())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkHomeCodeViewable(ctx *context.Context) {
|
func checkHomeCodeViewable(ctx *context.Context) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user