From 2d476ea4f6dea8303ef0858ad3c43079b5b2c7e3 Mon Sep 17 00:00:00 2001 From: xing Date: Sun, 12 Mar 2023 20:41:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{components => widgets}/constraints.go | 2 +- internal/theme/fs.go | 2 +- internal/theme/twentyfifteen/twentyfifteen.go | 7 +- .../twentyseventeen/layout/sidebar.gohtml | 18 +---- .../theme/twentyseventeen/twentyseventeen.go | 3 +- internal/theme/wp/components/block.go | 71 +++++++++++++++++++ .../wp/{ => components/widget}/archive.go | 15 ++-- .../theme/wp/components/widget/archive.gohtml | 38 ---------- .../components/widget/recent-comments.gohtml | 14 ---- .../wp/components/widget/recent-posts.gohtml | 18 ----- .../{ => components/widget}/recentcomments.go | 11 +-- .../wp/{ => components/widget}/recentposts.go | 13 ++-- .../wp/{ => components/widget}/search.go | 11 +-- .../theme/wp/components/widgetareadata.go | 33 +++++++++ internal/theme/wp/widgetareadata.go | 31 -------- 15 files changed, 140 insertions(+), 147 deletions(-) rename internal/pkg/constraints/{components => widgets}/constraints.go (89%) create mode 100644 internal/theme/wp/components/block.go rename internal/theme/wp/{ => components/widget}/archive.go (87%) delete mode 100644 internal/theme/wp/components/widget/archive.gohtml delete mode 100644 internal/theme/wp/components/widget/recent-comments.gohtml delete mode 100644 internal/theme/wp/components/widget/recent-posts.gohtml rename internal/theme/wp/{ => components/widget}/recentcomments.go (87%) rename internal/theme/wp/{ => components/widget}/recentposts.go (87%) rename internal/theme/wp/{ => components/widget}/search.go (88%) create mode 100644 internal/theme/wp/components/widgetareadata.go delete mode 100644 internal/theme/wp/widgetareadata.go diff --git a/internal/pkg/constraints/components/constraints.go b/internal/pkg/constraints/widgets/constraints.go similarity index 89% rename from internal/pkg/constraints/components/constraints.go rename to internal/pkg/constraints/widgets/constraints.go index ae9b950..c978f70 100644 --- a/internal/pkg/constraints/components/constraints.go +++ b/internal/pkg/constraints/widgets/constraints.go @@ -1,4 +1,4 @@ -package components +package widgets const ( SearchFormArgs = "SearchFormArgs" diff --git a/internal/theme/fs.go b/internal/theme/fs.go index 2563a58..9a1be26 100644 --- a/internal/theme/fs.go +++ b/internal/theme/fs.go @@ -38,7 +38,7 @@ func commonTemplate(t *multipTemplate.MultipleFsTemplate) { for _, main := range m { file := filepath.Base(main) dir := strings.Split(main, "/")[0] - templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "wp/template.gohtml", "wp/*/*/*.gohtml")) + templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "wp/template.gohtml")) t.SetTemplate(main, templ) } } diff --git a/internal/theme/twentyfifteen/twentyfifteen.go b/internal/theme/twentyfifteen/twentyfifteen.go index 90e7f18..5ab6ebb 100644 --- a/internal/theme/twentyfifteen/twentyfifteen.go +++ b/internal/theme/twentyfifteen/twentyfifteen.go @@ -5,10 +5,11 @@ import ( "encoding/json" "github.com/fthvgb1/wp-go/internal/pkg/config" "github.com/fthvgb1/wp-go/internal/pkg/constraints" - "github.com/fthvgb1/wp-go/internal/pkg/constraints/components" + "github.com/fthvgb1/wp-go/internal/pkg/constraints/widgets" "github.com/fthvgb1/wp-go/internal/pkg/logs" "github.com/fthvgb1/wp-go/internal/plugins/wphandle" "github.com/fthvgb1/wp-go/internal/theme/wp" + "github.com/fthvgb1/wp-go/internal/theme/wp/components" "strings" ) @@ -39,9 +40,9 @@ func Hook(h *wp.Handle) { } func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) { - h.WidgetArea() + components.WidgetArea(h) h.GetPassword() - h.PushComponentFilterFn(components.SearchFormArgs, func(h *wp.Handle, s string) string { + h.PushComponentFilterFn(widgets.SearchFormArgs, func(h *wp.Handle, s string) string { return strings.ReplaceAll(s, `class="search-submit"`, `class="search-submit screen-reader-text"`) }) wphandle.RegisterPlugins(h, config.GetConfig().Plugins...) diff --git a/internal/theme/twentyseventeen/layout/sidebar.gohtml b/internal/theme/twentyseventeen/layout/sidebar.gohtml index 1bc0095..37b69ba 100644 --- a/internal/theme/twentyseventeen/layout/sidebar.gohtml +++ b/internal/theme/twentyseventeen/layout/sidebar.gohtml @@ -1,21 +1,5 @@ {{define "layout/sidebar" }} - - {{template "common/recent-posts" .}} - {{template "common/recent-comments" .}} - {{template "common/archives" .}} + {{template "common/sidebarWidget" .}}

分类