Compare commits
2 Commits
9af2a04a97
...
2ca1f10bfc
Author | SHA1 | Date | |
---|---|---|---|
|
2ca1f10bfc | ||
|
ae20829209 |
|
@ -78,6 +78,13 @@ func (b *Builder) WriteString(s ...string) (count int) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Replace(s string, replace map[string]string) string {
|
||||
for k, v := range replace {
|
||||
s = strings.ReplaceAll(s, k, v)
|
||||
}
|
||||
return s
|
||||
}
|
||||
func (b *Builder) Sprintf(format string, a ...any) int {
|
||||
i, _ := fmt.Fprintf(b, format, a...)
|
||||
return i
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func colorScheme(h *wp.Handle) (r string) {
|
||||
|
@ -15,16 +14,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))
|
||||
css := customCss
|
||||
for k, v := range map[string]string{
|
||||
reducedSaturation := fmt.Sprintf("%d%%", int(.8*50))
|
||||
saturation := fmt.Sprintf("%d%%", 50)
|
||||
css := str.Replace(customCss, map[string]string{
|
||||
"' . $hue . '": hue,
|
||||
"' . esc_attr( $hue ) . '": hue,
|
||||
"' . $saturation . '": saturation,
|
||||
"' . esc_attr( $saturation ) .' ": saturation,
|
||||
} {
|
||||
css = strings.ReplaceAll(css, k, v)
|
||||
}
|
||||
"' . $reduced_saturation . '": reducedSaturation,
|
||||
})
|
||||
s.Sprintf(`<style type="text/css" id="custom-theme-colors">%s</style>`, css)
|
||||
r = s.String()
|
||||
return
|
||||
|
|
|
@ -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 {
|
||||
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"`
|
||||
Slug string `json:"slug"`
|
||||
Gradient string `json:"gradient"`
|
||||
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
|
||||
|
|
|
@ -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 = `<a class="prev page-numbers" href="%s"><svg class="icon icon-arrow-left" aria-hidden="true" role="img"> <use href="#icon-arrow-left" xlink:href="#icon-arrow-left"></use> </svg>
|
||||
|
@ -41,6 +51,11 @@ func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
|||
wp.NewComponents(colorScheme, 10),
|
||||
wp.NewComponents(customHeader, 10),
|
||||
)
|
||||
if "dark" == wpconfig.GetThemeModsVal(ThemeName, "colorscheme", "light") {
|
||||
h.PushHeadScript(wp.NewComponents(func(h *wp.Handle) string {
|
||||
return ` <link rel="stylesheet" id="twentyseventeen-colors-dark-css" href="/wp-content/themes/twentyseventeen/assets/css/colors-dark.css?ver=20191025" media="all">`
|
||||
}, 10))
|
||||
}
|
||||
h.SetData("HeaderImage", getHeaderImage(h))
|
||||
h.SetData("scene", h.Scene())
|
||||
next(h)
|
||||
|
|
Loading…
Reference in New Issue
Block a user