Documented the theming part a bit better

pull/20/head^2
Slatian 2022-12-03 22:49:04 +01:00 zatwierdzone przez Alexander Cobleigh
rodzic 9173912782
commit 22d1802337
2 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -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"

Wyświetl plik

@ -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)
}