From d211e49036e265efc6028ab3278ec3853b463c66 Mon Sep 17 00:00:00 2001 From: xing Date: Sat, 11 Mar 2023 23:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=92=E6=A1=A3=E7=BB=84=E4=BB=B6=E5=8C=96?= =?UTF-8?q?=20=E5=8F=8A=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD=E4=BE=A7?= =?UTF-8?q?=E8=BE=B9=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/slice/slice.go | 6 + .../pkg/constraints/components/constraints.go | 8 ++ internal/pkg/constraints/const.go | 5 +- .../theme/twentyfifteen/layout/sidebar.gohtml | 17 +-- internal/theme/twentyfifteen/twentyfifteen.go | 7 +- .../theme/twentyseventeen/twentyseventeen.go | 2 +- internal/theme/wp/archive.go | 113 ++++++++++++++++++ internal/theme/wp/components/constraints.go | 6 - internal/theme/wp/recentcomments.go | 4 +- internal/theme/wp/recentposts.go | 4 +- internal/theme/wp/search.go | 7 +- internal/theme/wp/template.gohtml | 6 + internal/theme/wp/widgetareadata.go | 59 ++++----- internal/theme/wp/wp.go | 81 ++++++++----- 14 files changed, 223 insertions(+), 102 deletions(-) create mode 100644 internal/pkg/constraints/components/constraints.go create mode 100644 internal/theme/wp/archive.go delete mode 100644 internal/theme/wp/components/constraints.go diff --git a/helper/slice/slice.go b/helper/slice/slice.go index 61e83d9..7ecd8e3 100644 --- a/helper/slice/slice.go +++ b/helper/slice/slice.go @@ -280,3 +280,9 @@ func IndexOf[T comparable](a []T, v T) int { } return -1 } + +func ForEach[T any](a []T, fn func(i int, v T)) { + for i, t := range a { + fn(i, t) + } +} diff --git a/internal/pkg/constraints/components/constraints.go b/internal/pkg/constraints/components/constraints.go new file mode 100644 index 0000000..ae9b950 --- /dev/null +++ b/internal/pkg/constraints/components/constraints.go @@ -0,0 +1,8 @@ +package components + +const ( + SearchFormArgs = "SearchFormArgs" + RecentPostsArgs = "RecentPostsArgs" + RecentCommentsArgs = "RecentCommentsArgs" + ArchiveArgs = "ArchiveArgs" +) diff --git a/internal/pkg/constraints/const.go b/internal/pkg/constraints/const.go index ff7452d..89a7c71 100644 --- a/internal/pkg/constraints/const.go +++ b/internal/pkg/constraints/const.go @@ -17,6 +17,7 @@ const ( Defaults = "default" - HeadScript = "headScript" - FooterScript = "footerScript" + HeadScript = "headScript" + FooterScript = "footerScript" + SidebarsWidgets = "sidebarsWidgets" ) diff --git a/internal/theme/twentyfifteen/layout/sidebar.gohtml b/internal/theme/twentyfifteen/layout/sidebar.gohtml index 67b5a6c..02bad3c 100644 --- a/internal/theme/twentyfifteen/layout/sidebar.gohtml +++ b/internal/theme/twentyfifteen/layout/sidebar.gohtml @@ -1,20 +1,7 @@ {{define "layout/sidebar" }}