Skip to content

Commit

Permalink
Add custom dark mode brightness percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-aiken committed Nov 26, 2023
1 parent 16c4b8d commit 4716dbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ lazyPlaceholderCol = "/assets/lazyload/dsrca_loading_480x540.svg"
# Let images display in full brightness under dark mode
# disableDarkImage = true

# Specify image brightness in dark mode
# darkImageLevel = "85%"

[markup]
[markup.goldmark]
[markup.goldmark.renderer]
Expand Down
5 changes: 3 additions & 2 deletions layouts/partials/styles.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{{ if ne .Site.Params.disableDarkImage true }}
{{ $darkImageLevel := default "60%" .Site.Params.darkImageLevel }}
<style>
@media (prefers-color-scheme: dark) {
body[data-theme='auto'] img {
filter: brightness(60%);
filter: brightness({{ $darkImageLevel }});
}
}

body[data-theme='dark'] img {
filter: brightness(60%);
filter: brightness({{ $darkImageLevel }});
}
</style>
{{ end }}

0 comments on commit 4716dbe

Please sign in to comment.