From ae20829209276e3c2b5fb6ebcd3bdd5b7615ae69 Mon Sep 17 00:00:00 2001 From: xing Date: Wed, 1 Mar 2023 22:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84twentyseventeen=E7=9A=84=20?= =?UTF-8?q?=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/theme/theme.go | 1 + internal/theme/twentyseventeen/colorscheme.go | 4 +- .../theme/twentyseventeen/themesupport.go | 82 +++++++++++++++++-- .../theme/twentyseventeen/twentyseventeen.go | 15 ++++ 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/internal/theme/theme.go b/internal/theme/theme.go index 79ef17f..bb57dc7 100644 --- a/internal/theme/theme.go +++ b/internal/theme/theme.go @@ -11,6 +11,7 @@ func InitTheme() { addThemeHookFunc(twentyfifteen.ThemeName, twentyfifteen.Hook) twentyfifteen.Init(TemplateFs) addThemeHookFunc(twentyseventeen.ThemeName, twentyseventeen.Hook) + twentyseventeen.Init(TemplateFs) } func GetTemplateName() string { diff --git a/internal/theme/twentyseventeen/colorscheme.go b/internal/theme/twentyseventeen/colorscheme.go index 223733d..300087a 100644 --- a/internal/theme/twentyseventeen/colorscheme.go +++ b/internal/theme/twentyseventeen/colorscheme.go @@ -15,13 +15,15 @@ func colorScheme(h *wp.Handle) (r string) { } s := str.NewBuilder() hue := number.ToString(wpconfig.GetThemeModsVal[int64](ThemeName, "colorscheme_hue", 250)) - saturation := fmt.Sprintf("%d%%", int(.8*50)) + reducedSaturation := fmt.Sprintf("%d%%", int(.8*50)) + saturation := fmt.Sprintf("%d%%", 50) css := customCss for k, v := range map[string]string{ "' . $hue . '": hue, "' . esc_attr( $hue ) . '": hue, "' . $saturation . '": saturation, "' . esc_attr( $saturation ) .' ": saturation, + "' . $reduced_saturation . '": reducedSaturation, } { css = strings.ReplaceAll(css, k, v) } diff --git a/internal/theme/twentyseventeen/themesupport.go b/internal/theme/twentyseventeen/themesupport.go index 6797376..35cece2 100644 --- a/internal/theme/twentyseventeen/themesupport.go +++ b/internal/theme/twentyseventeen/themesupport.go @@ -1,17 +1,81 @@ package twentyseventeen type themeSupport struct { + CustomLineHeight bool `json:"custom-line-height"` + StarterContent StarterContent `json:"starter-content"` } -type EditorColorPalette struct { - Name string `json:"name"` - Slug string `json:"slug"` - Color string `json:"color"` +type Widgets struct { + Sidebar1 []string `json:"sidebar-1"` + Sidebar2 []string `json:"sidebar-2"` + Sidebar3 []string `json:"sidebar-3"` } -type EditorGradientPresets struct { - Name string `json:"name"` - Slug string `json:"slug"` - Gradient string `json:"gradient"` +type About struct { + Thumbnail string `json:"thumbnail"` +} +type Contact struct { + Thumbnail string `json:"thumbnail"` +} +type Blog struct { + Thumbnail string `json:"thumbnail"` +} +type HomepageSection struct { + Thumbnail string `json:"thumbnail"` +} +type Posts struct { + Num0 string `json:"0"` + About About `json:"about"` + Contact Contact `json:"contact"` + Blog Blog `json:"blog"` + HomepageSection HomepageSection `json:"homepage-section"` +} +type ImageEspresso struct { + PostTitle string `json:"post_title"` + File string `json:"file"` +} +type ImageSandwich struct { + PostTitle string `json:"post_title"` + File string `json:"file"` +} +type ImageCoffee struct { + PostTitle string `json:"post_title"` + File string `json:"file"` +} +type Attachments struct { + ImageEspresso ImageEspresso `json:"image-espresso"` + ImageSandwich ImageSandwich `json:"image-sandwich"` + ImageCoffee ImageCoffee `json:"image-coffee"` +} +type Options struct { + ShowOnFront string `json:"show_on_front"` + PageOnFront string `json:"page_on_front"` + PageForPosts string `json:"page_for_posts"` +} +type ThemeMods struct { + Panel1 string `json:"panel_1"` + Panel2 string `json:"panel_2"` + Panel3 string `json:"panel_3"` + Panel4 string `json:"panel_4"` +} +type Top struct { + Name string `json:"name"` + Items []string `json:"items"` +} +type Social struct { + Name string `json:"name"` + Items []string `json:"items"` +} +type NavMenus struct { + Top Top `json:"top"` + Social Social `json:"social"` +} +type StarterContent struct { + Widgets Widgets `json:"widgets"` + Posts Posts `json:"posts"` + Attachments Attachments `json:"attachments"` + Options Options `json:"options"` + ThemeMods ThemeMods `json:"theme_mods"` + NavMenus NavMenus `json:"nav_menus"` } -var themesupport = themeSupport{} +var themesupport themeSupport diff --git a/internal/theme/twentyseventeen/twentyseventeen.go b/internal/theme/twentyseventeen/twentyseventeen.go index 21449af..bf72e8d 100644 --- a/internal/theme/twentyseventeen/twentyseventeen.go +++ b/internal/theme/twentyseventeen/twentyseventeen.go @@ -1,6 +1,8 @@ package twentyseventeen import ( + "embed" + "encoding/json" "fmt" "github.com/fthvgb1/wp-go/helper" "github.com/fthvgb1/wp-go/helper/maps" @@ -17,6 +19,14 @@ import ( const ThemeName = "twentyseventeen" +func Init(fs embed.FS) { + b, err := fs.ReadFile(str.Join(ThemeName, "/themesupport.json")) + if err != nil { + return + } + err = json.Unmarshal(b, &themesupport) +} + var paginate = func() plugins.PageEle { p := plugins.TwentyFifteenPagination() p.PrevEle = `