diff --git a/internal/theme/common/bodyclass.go b/internal/theme/common/bodyclass.go index 0751ccf..c911eb0 100644 --- a/internal/theme/common/bodyclass.go +++ b/internal/theme/common/bodyclass.go @@ -12,11 +12,11 @@ import ( ) var commonClass = map[int]string{ - constraints.Home: "home blog", - constraints.Archive: "archive date", + constraints.Home: "home blog ", + constraints.Archive: "archive date ", constraints.Category: "archive category ", constraints.Tag: "archive category ", - constraints.Search: "search", + constraints.Search: "search ", constraints.Detail: "post-template-default single single-post ", } diff --git a/internal/theme/common/common.go b/internal/theme/common/common.go index e0acc30..e9e2073 100644 --- a/internal/theme/common/common.go +++ b/internal/theme/common/common.go @@ -69,13 +69,14 @@ func (h *Handle) Render() { h.Templ = str.Join(h.Theme, "/posts/detail.gohtml") } } + for _, fn := range h.HandleFns { + fn(h) + } h.AutoCal("siteIcon", h.CalSiteIcon) h.AutoCal("customLogo", h.CalCustomLogo) h.AutoCal("customCss", h.CalCustomCss) h.CalBodyClass() - for _, fn := range h.HandleFns { - fn(h) - } + h.C.HTML(h.Code, h.Templ, h.GinH) } diff --git a/internal/theme/common/detail.go b/internal/theme/common/detail.go index 0052ac2..918b20a 100644 --- a/internal/theme/common/detail.go +++ b/internal/theme/common/detail.go @@ -17,20 +17,25 @@ type DetailHandle struct { CommentRender plugins.CommentHtml Comments []models.Comments Post models.Posts + Pipes []HandlePipeFn[*DetailHandle] } func NewDetailHandle(handle *Handle) *DetailHandle { return &DetailHandle{Handle: handle} } +func (d *DetailHandle) Pipe(calls ...HandlePipeFn[*DetailHandle]) { + HandlePipe[*DetailHandle](append(calls, d.Pipes...), func(d *DetailHandle) { + d.Render() + })(d) +} + func (d *DetailHandle) BuildDetailData() (err error) { d.GinH["title"] = wpconfig.GetOption("blogname") err = d.CheckAndGetPost() if err != nil { return } - d.WidgetAreaData() - d.GetPassword() d.Comment() d.ContextPost() return @@ -73,6 +78,9 @@ func (d *DetailHandle) Comment() { } func (d *DetailHandle) RenderComment() { + if d.CommentRender == nil { + d.CommentRender = plugins.CommentRender() + } ableComment := true if d.Post.CommentStatus != "open" || (d.Post.PostPassword != "" && d.Password != d.Post.PostPassword) { @@ -94,19 +102,8 @@ func (d *DetailHandle) ContextPost() { func (d *DetailHandle) Render() { d.PasswordProject() - if d.CommentRender == nil { - d.CommentRender = plugins.CommentRender() - } - d.CalBodyClass() - d.AutoCal("siteIcon", d.CalSiteIcon) - d.AutoCal("customLogo", d.CalCustomLogo) - d.AutoCal("customCss", d.CalCustomCss) d.RenderComment() - d.CalBodyClass() - if d.Templ == "" { - d.Templ = fmt.Sprintf("%s/posts/detail.gohtml", d.Theme) - } - d.C.HTML(d.Code, d.Templ, d.GinH) + d.Handle.Render() } func (d *DetailHandle) Details() { @@ -117,6 +114,5 @@ func (d *DetailHandle) Details() { d.C.HTML(d.Code, d.Templ, d.GinH) return } - d.ExecHandlePlugin() d.Render() } diff --git a/internal/theme/twentyseventeen/layout/base.gohtml b/internal/theme/twentyseventeen/layout/base.gohtml index 6fd5deb..c698b8f 100644 --- a/internal/theme/twentyseventeen/layout/base.gohtml +++ b/internal/theme/twentyseventeen/layout/base.gohtml @@ -6,7 +6,7 @@ {{block "head" .}} {{end}} -
+ {{template "svg"}}