Skip to content

Commit

Permalink
✨ feat: add browser_theme_color config option
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Sep 9, 2023
1 parent 9acaba6 commit 5186104
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ default_theme = "light"
# All other skins have optimal contrast.
skin = ""

# Set browser theme colour. Can be a single colour or [light, dark].
# Note: Bright colors may be ignored in dark mode.
# More details: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color
browser_theme_color = "#087e96"
# browser_theme_color = ["#ffffff", "#000000"] # Example of light/dark colours.

# List additional stylesheets to load site-wide.
# These stylesheets should be located in your site's `static` directory.
# Example: stylesheets = ["extra1.css", "path/extra2.css"]
Expand Down
10 changes: 10 additions & 0 deletions templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@

<meta name="color-scheme" content="{%- if config.extra.theme_switcher -%}light dark{%- elif config.extra.default_theme -%}{{config.extra.default_theme}}{%- else -%}light{%- endif -%}" />

{%- set theme_color = config.extra.browser_theme_color | default(value="#defaultColor") -%}
{%- if theme_color is iterable -%}
{# Handle array values: theme_color[0] for light mode, theme_color[1] for dark mode #}
<meta name="theme-color" media="(prefers-color-scheme: light)" content="{{ theme_color[0] }}" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="{{ theme_color[1] }}" />
{%- else -%}
{# Handle single value #}
<meta name="theme-color" content="{{ theme_color }}" />
{%- endif -%}

{%- if page.description %}
<meta name="description" content="{{ page.description | striptags | safe }}" />
<meta property="og:description" content="{{ page.description | striptags | safe }}" />
Expand Down
6 changes: 6 additions & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ default_theme = "light"
# All other skins have optimal contrast.
skin = ""

# Set browser theme colour. Can be a single colour or [light, dark].
# Note: Bright colors may be ignored in dark mode.
# More details: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color
# browser_theme_color = "#087e96" # Example of single value.
# browser_theme_color = ["#ffffff", "#000000"] # Example of light/dark colours.

# List additional stylesheets to load site-wide.
# These stylesheets should be located in your site's `static` directory.
# Example: stylesheets = ["extra1.css", "path/extra2.css"]
Expand Down

0 comments on commit 5186104

Please sign in to comment.