diff --git a/internal/plugins/wphandle/enlightjs/enlighterjs.go b/internal/plugins/wphandle/enlightjs/enlighterjs.go index 8a994d5..7f6c5cd 100644 --- a/internal/plugins/wphandle/enlightjs/enlighterjs.go +++ b/internal/plugins/wphandle/enlightjs/enlighterjs.go @@ -10,7 +10,7 @@ func EnlighterJS(h *wp.Handle) { return `` }) - h.PushGroupFooterScript(20, func(h *wp.Handle) string { + h.PushGroupFooterScript(10, func(h *wp.Handle) string { return str.Join(``, "\n", enlighterjs) }) } diff --git a/internal/theme/twentyfifteen/posts/detail.gohtml b/internal/theme/twentyfifteen/posts/detail.gohtml index ce9c883..b0935be 100644 --- a/internal/theme/twentyfifteen/posts/detail.gohtml +++ b/internal/theme/twentyfifteen/posts/detail.gohtml @@ -56,7 +56,7 @@ {{end}} - {{if eq .post.CommentStatus "open"}} + {{if and (eq .post.CommentStatus "open") (eq ( "thread_comments" |getOption ) "1")}}

发表回复 diff --git a/internal/theme/twentyseventeen/layout/base.gohtml b/internal/theme/twentyseventeen/layout/base.gohtml index bf92e71..fec5e20 100644 --- a/internal/theme/twentyseventeen/layout/base.gohtml +++ b/internal/theme/twentyseventeen/layout/base.gohtml @@ -40,24 +40,12 @@

- - - {{block "content" .}} {{end}} - - - {{template "layout/footer" .}} diff --git a/internal/theme/twentyseventeen/layout/colophon.gohtml b/internal/theme/twentyseventeen/layout/colophon.gohtml new file mode 100644 index 0000000..efb3fa9 --- /dev/null +++ b/internal/theme/twentyseventeen/layout/colophon.gohtml @@ -0,0 +1,9 @@ +{{define "layout/colophon"}} + +{{end}} \ No newline at end of file diff --git a/internal/theme/twentyseventeen/layout/footer.gohtml b/internal/theme/twentyseventeen/layout/footer.gohtml index b66acb5..8509af3 100644 --- a/internal/theme/twentyseventeen/layout/footer.gohtml +++ b/internal/theme/twentyseventeen/layout/footer.gohtml @@ -1,11 +1,4 @@ {{define "layout/footer"}} - - - - - {{template "common/footer" .}} {{ block "footer" .}} {{end}} diff --git a/internal/theme/twentyseventeen/layout/head.gohtml b/internal/theme/twentyseventeen/layout/head.gohtml index 015ba2e..9e80cff 100644 --- a/internal/theme/twentyseventeen/layout/head.gohtml +++ b/internal/theme/twentyseventeen/layout/head.gohtml @@ -4,9 +4,6 @@ - {{ .title }} @@ -48,24 +45,8 @@ .wp-block-pullquote{font-size: 1.5em;line-height: 1.6;} - - - - - - - - - - - - + {{template "common/head" .}} {{block "head" .}} {{end}} - {{template "common/head" .}} {{end}} \ No newline at end of file diff --git a/internal/theme/twentyseventeen/posts/detail.gohtml b/internal/theme/twentyseventeen/posts/detail.gohtml index 2545935..9e5610e 100644 --- a/internal/theme/twentyseventeen/posts/detail.gohtml +++ b/internal/theme/twentyseventeen/posts/detail.gohtml @@ -122,6 +122,9 @@ + + {{template "layout/colophon"}} + {{else}} diff --git a/internal/theme/twentyseventeen/posts/index.gohtml b/internal/theme/twentyseventeen/posts/index.gohtml index d7ec11f..47d34b5 100644 --- a/internal/theme/twentyseventeen/posts/index.gohtml +++ b/internal/theme/twentyseventeen/posts/index.gohtml @@ -73,7 +73,7 @@ {{template "layout/empty" .}} {{end}} - {{end}} - + {{template "layout/colophon"}} +{{end}} \ No newline at end of file diff --git a/internal/theme/twentyseventeen/script.go b/internal/theme/twentyseventeen/script.go new file mode 100644 index 0000000..9425f34 --- /dev/null +++ b/internal/theme/twentyseventeen/script.go @@ -0,0 +1,47 @@ +package twentyseventeen + +import ( + "fmt" + "github.com/fthvgb1/wp-go/internal/theme/wp" + "github.com/fthvgb1/wp-go/internal/wpconfig" +) + +func pushHeadScripts(h *wp.Handle) { + var head = headScript + h.PushGroupHeadScript(30, func(h *wp.Handle) string { + return head + }) +} + +func pushFooterScripts(h *wp.Handle) { + var footer = footerScript + h.PushGroupFooterScript(20, func(h *wp.Handle) string { + if "dark" == wpconfig.GetThemeModsVal(ThemeName, "colorscheme", "light") { + footer = fmt.Sprintf("%s\n%s", footerScript, ` `) + } + return footer + }) +} + +var headScript = ` + + + + + + + + + ` + +var footerScript = ` + + + + ` diff --git a/internal/theme/twentyseventeen/twentyseventeen.go b/internal/theme/twentyseventeen/twentyseventeen.go index 30a9c67..d8c9253 100644 --- a/internal/theme/twentyseventeen/twentyseventeen.go +++ b/internal/theme/twentyseventeen/twentyseventeen.go @@ -56,12 +56,8 @@ func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) { h.PushHandleFn(constraints.ParamError, errHandle) h.PushHandleFn(constraints.InternalErr, errHandle) h.PushGroupHeadScript(10, colorScheme, customHeader) - - if "dark" == wpconfig.GetThemeModsVal(ThemeName, "colorscheme", "light") { - h.PushHeadScript(wp.NewComponents(func(h *wp.Handle) string { - return ` ` - }, 10)) - } + pushHeadScripts(h) + pushFooterScripts(h) h.SetData("HeaderImage", getHeaderImage(h)) h.SetData("scene", h.Scene()) next(h) diff --git a/internal/theme/wp/detail.go b/internal/theme/wp/detail.go index f087820..3fd670c 100644 --- a/internal/theme/wp/detail.go +++ b/internal/theme/wp/detail.go @@ -101,8 +101,10 @@ func (d *DetailHandle) ContextPost() { } func (d *DetailHandle) Render() { + d.PreCodeAndStats() + d.PreTemplate() if d.Post.CommentStatus == "open" && wpconfig.GetOption("thread_comments") == "1" { - d.PushGroupFooterScript(30, func(h *Handle) string { + d.PushGroupFooterScript(10, func(h *Handle) string { return `` }) } diff --git a/internal/theme/wp/index.go b/internal/theme/wp/index.go index cb8be2e..46929c9 100644 --- a/internal/theme/wp/index.go +++ b/internal/theme/wp/index.go @@ -142,11 +142,14 @@ func (i *IndexHandle) ExecPostsPlugin(calls ...func(*models.Posts)) { } func (i *IndexHandle) Render() { + i.PreCodeAndStats() + i.PreTemplate() i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) { i.ExecPostsPlugin() i.Pagination() i.ginH["posts"] = i.Posts }, 10)) + i.Handle.Render() } diff --git a/internal/theme/wp/wp.go b/internal/theme/wp/wp.go index 110e5d8..c680a97 100644 --- a/internal/theme/wp/wp.go +++ b/internal/theme/wp/wp.go @@ -201,21 +201,19 @@ func (h *Handle) PreCodeAndStats() { } func (h *Handle) Render() { - h.PreCodeAndStats() - h.PreTemplate() + h.CommonComponents() + h.ExecHandleFns() +} + +func (h *Handle) CommonComponents() { h.AddComponent("customLogo", CalCustomLogo) - h.PushGroupHeadScript(0, CalSiteIcon, CalCustomCss) - h.PushHandleFn(constraints.AllStats, NewHandleFn(func(h *Handle) { h.CalMultipleComponents() h.CalBodyClass() }, 10), NewHandleFn(func(h *Handle) { h.C.HTML(h.Code, h.templ, h.ginH) }, 0)) - - h.ExecHandleFns() - } func (h *Handle) PushComponents(name string, components ...Components) {