Default dark theme with environment variable (#61)

* Created env variable for setting dark as default theme

* Docker variable simplified
This commit is contained in:
David
2021-10-24 16:08:35 +02:00
committed by GitHub
parent 064ce141cb
commit 3f0918edf3
3 changed files with 7 additions and 4 deletions

View File

@@ -23,4 +23,4 @@ ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
CMD NEXT_PUBLIC_SITE_DOMAIN=$site_domain yarn build && yarn start CMD NEXT_PUBLIC_SITE_DOMAIN=$site_domain DEFAULT_DARK_THEME=$dark_theme yarn build && yarn start

View File

@@ -32,9 +32,11 @@ As *Lingva* is a [NextJS](https://nextjs.org/) project you can deploy your own i
The only requirement is to set an environment variable called `NEXT_PUBLIC_SITE_DOMAIN` with the domain you're deploying the instance under. This is used for the canonical URL and the meta tags. The only requirement is to set an environment variable called `NEXT_PUBLIC_SITE_DOMAIN` with the domain you're deploying the instance under. This is used for the canonical URL and the meta tags.
Optionally, there's another environment variable available called `DEFAULT_DARK_THEME` for selecting dark as the default page theme on the first load. The theme will be light by default unless this variable is set to `true`.
### Docker ### Docker
An [official Docker image](https://hub.docker.com/r/thedaviddelta/lingva-translate) is available to ease the deployment using Compose, Kubernetes or similar technologies. Remember to also include the environment variable (simplified to `site_domain`) when running the container. An [official Docker image](https://hub.docker.com/r/thedaviddelta/lingva-translate) is available to ease the deployment using Compose, Kubernetes or similar technologies. Remember to also include the environment variables (simplified to `site_domain` and `dark_theme`) when running the container.
#### Docker Compose: #### Docker Compose:
@@ -49,6 +51,7 @@ services:
restart: unless-stopped restart: unless-stopped
environment: environment:
- site_domain=lingva.ml - site_domain=lingva.ml
- dark_theme=false
ports: ports:
- 3000:3000 - 3000:3000
``` ```
@@ -56,7 +59,7 @@ services:
#### Docker Run #### Docker Run
```bash ```bash
docker run -p 3000:3000 -e site_domain=lingva.ml thedaviddelta/lingva-translate:latest docker run -p 3000:3000 -e site_domain=lingva.ml -e dark_theme=false thedaviddelta/lingva-translate:latest
``` ```
### Vercel ### Vercel

View File

@@ -17,7 +17,7 @@ export default extendTheme({
} }
}, },
config: { config: {
initialColorMode: "light", initialColorMode: process.env["DEFAULT_DARK_THEME"] === "true" ? "dark" : "light",
useSystemColorMode: false useSystemColorMode: false
}, },
components: { components: {