Skip to content

Commit

Permalink
✨ feat: add browser_theme_color config option (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo authored Sep 9, 2023
1 parent 9acaba6 commit 772ca29
Show file tree
Hide file tree
Showing 3 changed files with 21 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
9 changes: 9 additions & 0 deletions templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@

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

{%- if config.extra.browser_theme_color and config.extra.browser_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="{{ config.extra.browser_theme_color[0] }}" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="{{ config.extra.browser_theme_color[1] }}" />
{%- elif config.extra.browser_theme_color -%}
{# Handle single value #}
<meta name="theme-color" content="{{ config.extra.browser_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 772ca29

Please sign in to comment.