mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-05-14 05:52:54 +00:00
Add theme support using environment variable (#145)
* Add theme support using environment variable * Propagate theme variable to template in options.go Propagate the `theme` variable from the environment to the template in `src/routes/options.go` * Retrieve the `theme` variable from the environment using `os.Getenv("THEME")` * Set the `theme` variable in the `gin.H` map when rendering the `home.html` template --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=6397c9b4-9450-425c-bbbe-019425965d2b). * Move all theme environment variable logic to a utils function Move theme environment variable logic to a utils function and update routes to use it. * Add `GetThemeFromEnv` function in `src/utils/theme.go` to derive the theme from environment variables and default to "auto" if not set. * Update `src/routes/home.go` to import and use `GetThemeFromEnv` in the `GetHome` function. * Update `src/routes/options.go` to import and use `GetThemeFromEnv` in the `ChangeOptions` function. * Update `src/routes/question.go` to import and use `GetThemeFromEnv` in the `ViewQuestion` function. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=a0dab6f3-027c-4f6e-85fe-60e7675d0e70). * fix: imports removed by copilot * fix: override theme in posthome * style: reduced repetition in themes with common vars
This commit is contained in:
parent
e35ffdcc07
commit
4c971f3121
7 changed files with 44 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html data-theme="{{ .theme }}">
|
||||
|
||||
<head>
|
||||
<title>AnonymousOverflow - Private frontend for StackOverflow</title>
|
||||
|
@ -58,4 +58,4 @@
|
|||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html data-theme="{{ .theme }}">
|
||||
|
||||
<head>
|
||||
<title>{{ .question.Title }} | AnonymousOverflow</title>
|
||||
|
@ -92,4 +92,4 @@
|
|||
{{ end }}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue