Skip to content

Commit

Permalink
fix: replace data-theme with data-bs-theme to be compatible with Boot…
Browse files Browse the repository at this point in the history
…strap dark mode
  • Loading branch information
razonyang committed Aug 16, 2022
1 parent d31e780 commit abca9c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion assets/js/mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class ModeToggle implements Component {
value = getPreferMode();
}
console.debug(`Switch to ${value} mode`);
document.body.parentElement.setAttribute('data-theme', value);
document.body.parentElement.setAttribute('data-theme', value); // TODO: remove in v1
document.body.parentElement.setAttribute('data-bs-theme', value);
const event = new CustomEvent('hbs:mode', { detail: { mode: value } });
document.dispatchEvent(event);
}
Expand Down
4 changes: 3 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{{- if not (in (slice "light" "dark" "auto") $color) }}
{{- $color = "auto" }}
{{- end }}
<html class="position-relative" itemscope itemtype="http:https://schema.org/WebPage" lang="{{ .Lang }}" data-theme="{{ $color }}"
<html class="position-relative" itemscope itemtype="http:https://schema.org/WebPage" lang="{{ .Lang }}"
data-theme="{{ $color }}" {{/* TODO: remove in v1 */}}
data-bs-theme="{{ $color }}"
{{- with $.Site.Language.LanguageDirection }} dir="{{ . }}"{{ end }}
{{- with $.Site.Params.palette }} data-palette="{{ replace . " " "-" }}"{{ end }}>
<head>
Expand Down

0 comments on commit abca9c0

Please sign in to comment.