diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index 95ccab35258..0bc730121a4 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -2,6 +2,8 @@ ## In this release +- ([#12700](https://github.com/quarto-dev/quarto-cli/issues/12700)): Giscus not loading on a site without dark mode configured. + ## In previous releases - ([#6607](https://github.com/quarto-dev/quarto-cli/issues/6607)): Add missing beamer template update for beamer theme options: `colorthemeoptions`, `fontthemeoptions`, `innerthemeoptions` and `outerthemeoptions`. diff --git a/src/format/html/format-html.ts b/src/format/html/format-html.ts index 9f35fd599a0..e2bfc2a9830 100644 --- a/src/format/html/format-html.ts +++ b/src/format/html/format-html.ts @@ -609,7 +609,7 @@ export async function htmlFormatExtras( giscusAfterBody, renderEjs( formatResourcePath("html", join("giscus", "giscus.ejs")), - { giscus }, + { giscus, darkMode: options.darkMode }, ), ); includeAfterBody.push(giscusAfterBody); diff --git a/src/resources/formats/html/giscus/giscus.ejs b/src/resources/formats/html/giscus/giscus.ejs index f12d5378394..31f8377f8fa 100644 --- a/src/resources/formats/html/giscus/giscus.ejs +++ b/src/resources/formats/html/giscus/giscus.ejs @@ -6,9 +6,11 @@ const getTheme = () => { let baseTheme = document.getElementById('giscus-base-theme').value; let altTheme = document.getElementById('giscus-alt-theme').value; + <% if (darkMode !== undefined) { %> if (authorPrefersDark) { [baseTheme, altTheme] = [altTheme, baseTheme]; } + <% } %> return document.body.classList.contains('quarto-dark') ? altTheme : baseTheme; }; const script = document.createElement("script");