Skip to content

Commit 8f61727

Browse files
put default stylesheet second for NoJS
1 parent 496d425 commit 8f61727

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/command/render/pandoc-html.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export async function resolveSassBundles(
130130
// Note that the other bundle provides light
131131
targets[0].attribs = {
132132
...targets[0].attribs,
133-
...attribForThemeStyle("light", defaultStyle),
133+
...attribForThemeStyle("light"),
134134
};
135135

136136
// Provide a dark bundle for this
@@ -144,14 +144,19 @@ export async function resolveSassBundles(
144144
bundle.key = bundle.key + "-dark";
145145
return bundle;
146146
});
147-
targets.unshift({
147+
const darkTarget = {
148148
name: `${dependency}-dark.min.css`,
149149
bundles: darkBundles as any,
150150
attribs: {
151151
"append-hash": "true",
152-
...attribForThemeStyle("dark", defaultStyle),
152+
...attribForThemeStyle("dark"),
153153
},
154-
});
154+
};
155+
if (defaultStyle === "dark") {
156+
targets.push(darkTarget);
157+
} else {
158+
targets.unshift(darkTarget);
159+
}
155160

156161
hasDarkStyles = true;
157162
}
@@ -303,7 +308,7 @@ async function resolveQuartoSyntaxHighlighting(
303308
extras = cloneDeep(extras);
304309

305310
// If we're using default highlighting, use theme darkness to select highlight style
306-
const mediaAttr = attribForThemeStyle(style, defaultStyle);
311+
const mediaAttr = attribForThemeStyle(style);
307312
if (style === "default") {
308313
if (extras.html?.[kTextHighlightingMode] === "dark") {
309314
style = "dark";
@@ -559,12 +564,10 @@ const kVariablesRegex =
559564
/\/\*\! quarto-variables-start \*\/([\S\s]*)\/\*\! quarto-variables-end \*\//g;
560565

561566
// Attributes for the style tag
562-
// Note that we default disable the dark mode and rely on JS to enable it
563567
function attribForThemeStyle(
564568
style: "dark" | "light" | "default",
565-
defaultStyle?: "dark" | "light",
566569
): Record<string, string> {
567-
const colorModeAttrs = (mode: string, disabled: boolean) => {
570+
const colorModeAttrs = (mode: string) => {
568571
const attr: Record<string, string> = {
569572
class: `quarto-color-scheme${
570573
mode === "dark" ? " quarto-color-alternate" : ""
@@ -575,9 +578,9 @@ function attribForThemeStyle(
575578

576579
switch (style) {
577580
case "dark":
578-
return colorModeAttrs("dark", defaultStyle !== "dark");
581+
return colorModeAttrs("dark");
579582
case "light":
580-
return colorModeAttrs("light", false);
583+
return colorModeAttrs("light");
581584
case "default":
582585
default:
583586
return {};

0 commit comments

Comments
 (0)