完善twentyseventeen的 配色
This commit is contained in:
parent
9af2a04a97
commit
ae20829209
@ -11,6 +11,7 @@ func InitTheme() {
|
|||||||
addThemeHookFunc(twentyfifteen.ThemeName, twentyfifteen.Hook)
|
addThemeHookFunc(twentyfifteen.ThemeName, twentyfifteen.Hook)
|
||||||
twentyfifteen.Init(TemplateFs)
|
twentyfifteen.Init(TemplateFs)
|
||||||
addThemeHookFunc(twentyseventeen.ThemeName, twentyseventeen.Hook)
|
addThemeHookFunc(twentyseventeen.ThemeName, twentyseventeen.Hook)
|
||||||
|
twentyseventeen.Init(TemplateFs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTemplateName() string {
|
func GetTemplateName() string {
|
||||||
|
@ -15,13 +15,15 @@ func colorScheme(h *wp.Handle) (r string) {
|
|||||||
}
|
}
|
||||||
s := str.NewBuilder()
|
s := str.NewBuilder()
|
||||||
hue := number.ToString(wpconfig.GetThemeModsVal[int64](ThemeName, "colorscheme_hue", 250))
|
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
|
css := customCss
|
||||||
for k, v := range map[string]string{
|
for k, v := range map[string]string{
|
||||||
"' . $hue . '": hue,
|
"' . $hue . '": hue,
|
||||||
"' . esc_attr( $hue ) . '": hue,
|
"' . esc_attr( $hue ) . '": hue,
|
||||||
"' . $saturation . '": saturation,
|
"' . $saturation . '": saturation,
|
||||||
"' . esc_attr( $saturation ) .' ": saturation,
|
"' . esc_attr( $saturation ) .' ": saturation,
|
||||||
|
"' . $reduced_saturation . '": reducedSaturation,
|
||||||
} {
|
} {
|
||||||
css = strings.ReplaceAll(css, k, v)
|
css = strings.ReplaceAll(css, k, v)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,81 @@
|
|||||||
package twentyseventeen
|
package twentyseventeen
|
||||||
|
|
||||||
type themeSupport struct {
|
type themeSupport struct {
|
||||||
|
CustomLineHeight bool `json:"custom-line-height"`
|
||||||
|
StarterContent StarterContent `json:"starter-content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditorColorPalette struct {
|
type Widgets struct {
|
||||||
Name string `json:"name"`
|
Sidebar1 []string `json:"sidebar-1"`
|
||||||
Slug string `json:"slug"`
|
Sidebar2 []string `json:"sidebar-2"`
|
||||||
Color string `json:"color"`
|
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"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Items []string `json:"items"`
|
||||||
Gradient string `json:"gradient"`
|
}
|
||||||
|
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
|
package twentyseventeen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fthvgb1/wp-go/helper"
|
"github.com/fthvgb1/wp-go/helper"
|
||||||
"github.com/fthvgb1/wp-go/helper/maps"
|
"github.com/fthvgb1/wp-go/helper/maps"
|
||||||
@ -17,6 +19,14 @@ import (
|
|||||||
|
|
||||||
const ThemeName = "twentyseventeen"
|
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 {
|
var paginate = func() plugins.PageEle {
|
||||||
p := plugins.TwentyFifteenPagination()
|
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>
|
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(colorScheme, 10),
|
||||||
wp.NewComponents(customHeader, 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("HeaderImage", getHeaderImage(h))
|
||||||
h.SetData("scene", h.Scene())
|
h.SetData("scene", h.Scene())
|
||||||
next(h)
|
next(h)
|
||||||
|
Loading…
Reference in New Issue
Block a user