Skip to content

Commit

Permalink
fix: wrong utterances theme
Browse files Browse the repository at this point in the history
When current theme is different from `defaultTheme`, it still gets
`defaultTheme`, instead of current theme.
  • Loading branch information
reuixiy committed Jun 24, 2020
1 parent f0b87b2 commit 9a041c1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions layouts/partials/third-party/utterances.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
script.crossOrigin = 'anonymous';
script.setAttribute('repo', '{{ .Site.Params.utterancesRepo }}');
script.setAttribute('issue-term', '{{ .Site.Params.utterancesIssueTerm }}');
script.setAttribute('theme', '{{ template "utterances-theme" . }}');
{{ template "utterances-theme" . }}
{{ with .Site.Params.utterancesLabel }}
script.setAttribute('label', '{{ . }}');
{{ end }}
Expand All @@ -22,5 +22,15 @@
{{- if and .Site.Params.enableDarkMode (eq .Site.Params.defaultTheme "dark") -}}
{{- $theme = .Site.Params.utterancesThemeDark | default "photon-dark" -}}
{{- end -}}
{{- $theme -}}

{{- if .Site.Params.enableDarkMode -}}
const isDark = getCurrentTheme() === 'dark';
if (isDark) {
script.setAttribute('theme', '{{ .Site.Params.utterancesThemeDark | default "photon-dark" }}');
} else {
script.setAttribute('theme', '{{ .Site.Params.utterancesTheme | default "github-light" }}');
}
{{- else -}}
script.setAttribute('theme', '{{ $theme }}');
{{- end -}}
{{- end -}}

0 comments on commit 9a041c1

Please sign in to comment.