小优化

This commit is contained in:
xing 2023-03-02 21:16:43 +08:00
parent 0d62ebd5a5
commit d3be997b8f
5 changed files with 7 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{{template "layout/base" .}} {{template "layout/base" .}}
{{define "content"}} {{define "content"}}
{{ if gt .post.Id 0}} {{ if and .post gt .post.Id 0}}
<div id="primary" class="content-area"> <div id="primary" class="content-area">
<main id="main" class="site-main"> <main id="main" class="site-main">
<article id="post-{{.post.Id}}" <article id="post-{{.post.Id}}"

View File

@ -37,10 +37,7 @@ func Hook(h *wp.Handle) {
func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) { func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
h.WidgetAreaData() h.WidgetAreaData()
h.GetPassword() h.GetPassword()
h.PushHeadScript( h.PushGroupHeadScript(10, CalCustomBackGround, colorSchemeCss)
wp.NewComponents(CalCustomBackGround, 10),
wp.NewComponents(colorSchemeCss, 10),
)
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10)) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
switch h.Scene() { switch h.Scene() {
case constraints.Detail: case constraints.Detail:

View File

@ -47,7 +47,7 @@ func Hook(h *wp.Handle) {
func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) { func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
h.WidgetAreaData() h.WidgetAreaData()
h.GetPassword() h.GetPassword()
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(calClass, 15)) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(calClass, 20))
errHandle := wp.NewHandleFn(errorsHandle, 100) errHandle := wp.NewHandleFn(errorsHandle, 100)
h.PushHandleFn(constraints.Error404, errHandle) h.PushHandleFn(constraints.Error404, errHandle)
h.PushHandleFn(constraints.ParamError, errHandle) h.PushHandleFn(constraints.ParamError, errHandle)

View File

@ -137,7 +137,7 @@ func (i *IndexHandle) ExecPostsPlugin(calls ...func(*models.Posts)) {
} }
plugin := GetListPostPlugins(pluginConf, postsPlugins) plugin := GetListPostPlugins(pluginConf, postsPlugins)
i.ginH["posts"] = slice.Map(i.Posts, PluginFn[models.Posts](plugin, i.Handle, Defaults(calls...))) i.Posts = slice.Map(i.Posts, PluginFn[models.Posts](plugin, i.Handle, Defaults(calls...)))
} }
@ -146,6 +146,7 @@ func (i *IndexHandle) Render() {
i.ExecPostsPlugin() i.ExecPostsPlugin()
i.Pagination() i.Pagination()
}, 10)) }, 10))
i.ginH["posts"] = i.Posts
i.Handle.Render() i.Handle.Render()
} }

View File

@ -202,12 +202,12 @@ func (h *Handle) Render() {
h.PreTemplate() h.PreTemplate()
h.AddComponent("customLogo", CalCustomLogo) h.AddComponent("customLogo", CalCustomLogo)
h.PushHeadScript(Components{CalSiteIcon, 100}, Components{CalCustomCss, 0}) h.PushGroupHeadScript(0, CalSiteIcon, CalCustomCss)
h.PushHandleFn(constraints.AllStats, NewHandleFn(func(h *Handle) { h.PushHandleFn(constraints.AllStats, NewHandleFn(func(h *Handle) {
h.CalMultipleComponents() h.CalMultipleComponents()
h.CalBodyClass() h.CalBodyClass()
}, 5), NewHandleFn(func(h *Handle) { }, 10), NewHandleFn(func(h *Handle) {
h.C.HTML(h.Code, h.templ, h.ginH) h.C.HTML(h.Code, h.templ, h.ginH)
}, 0)) }, 0))