diff --git a/docker/Dockerfile b/docker/Dockerfile index 8e9dc3f..6e3dac4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,6 +14,7 @@ RUN go build -ldflags="-s -w" cmd/godash/godash.go FROM node:${NODE_VERSION}-alpine AS nodeBuilder WORKDIR /app +COPY ./internal/router/templates.go ./internal/router/templates.go COPY ./web . RUN yarn install --frozen-lockfile RUN yarn run tailwind:build diff --git a/internal/bookmarks/types.go b/internal/bookmarks/types.go index 3e96b21..55149a3 100644 --- a/internal/bookmarks/types.go +++ b/internal/bookmarks/types.go @@ -6,7 +6,6 @@ type Config struct { Category string Entries []struct { Name string - Background bool URL string } } @@ -15,7 +14,7 @@ type Config struct { Entries []struct { Name string Icon string - Background bool + Background string URL string } } diff --git a/internal/router/templates.go b/internal/router/templates.go index de0b7b9..e053d23 100644 --- a/internal/router/templates.go +++ b/internal/router/templates.go @@ -8,6 +8,20 @@ import ( "github.com/labstack/echo/v4" ) +func backgroundColor(config string) string { + result := "p-[0.1rem] " + switch config { + case "dark": + return result + "bg-black " + case "light": + return result + "bg-white " + case "base": + return result + "bg-base-300 " + default: + return "" + } +} + type Template struct { templates *template.Template } @@ -18,6 +32,8 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con func initTemplates() *Template { return &Template{ - templates: template.Must(template.New("").Funcs(sprig.FuncMap()).ParseGlob("web/templates/*.html")), + templates: template.Must(template.New("").Funcs(sprig.FuncMap()).Funcs(template.FuncMap{ + "backgroundColor": backgroundColor, + }).ParseGlob("web/templates/*.html")), } } diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 7f6e798..d53fd82 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ["./templates/**/*.html"], + content: ["./templates/**/*.html", "../internal/router/templates.go"], theme: { container: { center: true diff --git a/web/templates/index.html b/web/templates/index.html index 3a17008..aa0856b 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -287,7 +287,7 @@
{{ range .Entries }} -
+
{{ .Name }}
{{ end }}