Skip to content

Commit bccafa7

Browse files
authored
Theme CLI flag to force light/dark mode (#79)
* Theme CLI flag to force light/dark mode * update usage
1 parent 4a7e9a5 commit bccafa7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

docs/Usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Usage of xlog:
6060
Site name is the name that appears on the header beside the logo and in the title tag (default "XLOG")
6161
-source string
6262
Directory that will act as a storage (default "/home/emad/code/xlog")
63+
-theme string
64+
bulma theme to use. (light, dark). empty value means system preference is used
6365
-twitter.username string
6466
user twitter account @handle. including the @
6567
```

flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Configuration struct {
1414
NotFoundPage string // name of the index page markdown file
1515
BindAddress string // bind address for the server
1616
ServeInsecure bool // should the server use https for cookie
17+
Theme string // empty switches between light/dark. setting it forces a theme
1718
CodeStyle string
1819
CsrfCookieName string
1920
DisabledExtensions string
@@ -37,4 +38,5 @@ func init() {
3738
flag.StringVar(&Config.CsrfCookieName, "csrf-cookie", "xlog_csrf", "CSRF cookie name")
3839
flag.StringVar(&Config.DisabledExtensions, "disabled-extensions", "", "disable list of extensions by name, comma separated")
3940
flag.StringVar(&Config.CodeStyle, "codestyle", "dracula", "code highlighting style name from the list supported by https://pkg.go.dev/github.com/alecthomas/chroma/v2/styles")
41+
flag.StringVar(&Config.Theme, "theme", "", "bulma theme to use. (light, dark). empty value means system preference is used")
4042
}

templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- define "header" -}}
22
<!DOCTYPE html>
3-
<html lang="en" {{with .csrf}}hx-headers='{"X-CSRF-Token":"{{.}}"}'{{end}}>
3+
<html lang="en" {{with .csrf}}hx-headers='{"X-CSRF-Token":"{{.}}"}'{{end}} {{with $.config.Theme}}data-theme="{{.}}"{{end}}>
44
<head>
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

0 commit comments

Comments
 (0)