kopia lustrzana https://github.com/cblgh/lieu
Documented the theming part a bit better
rodzic
9173912782
commit
22d1802337
|
@ -83,6 +83,8 @@ port = 10001
|
|||
|
||||
[theme]
|
||||
# colors specified in hex (or valid css names) which determine the theme of the lieu instance
|
||||
# NOTE: If (and only if) all three values are set lieu uses those to generate the file html/assets/theme.css at startup.
|
||||
# You can also write directly to that file istead of adding this section to your configuration file
|
||||
foreground = "#ffffff"
|
||||
background = "#000000"
|
||||
links = "#ffffff"
|
||||
|
|
|
@ -240,14 +240,15 @@ func (h RequestHandler) renderView(res http.ResponseWriter, tmpl string, view *T
|
|||
func WriteTheme(config types.Config) {
|
||||
theme := config.Theme
|
||||
// no theme is set, use the default
|
||||
if theme.Foreground == "" {
|
||||
if theme.Foreground == "" || theme.Background == "" || theme.Links =="" {
|
||||
return
|
||||
}
|
||||
colors := fmt.Sprintf(`:root {
|
||||
colors := fmt.Sprintf(`/*This file will be automatically regenerated by lieu on startup if the theme colors are set in the configuration file*/
|
||||
:root {
|
||||
--primary: %s;
|
||||
--secondary: %s;
|
||||
--link: %s;
|
||||
}\n`, theme.Foreground, theme.Background, theme.Links)
|
||||
}`, theme.Foreground, theme.Background, theme.Links)
|
||||
err := os.WriteFile("html/assets/theme.css", []byte(colors), 0644)
|
||||
util.Check(err)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue