Skip to content

Commit 9c1481e

Browse files
logo: transliterate windows paths to urls
1 parent 6bfc93d commit 9c1481e

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/format/dashboard/format-dashboard.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,26 @@ export function dashboardFormat() {
130130
alt: format.metadata[kLogoAlt] as string,
131131
};
132132
}
133-
format.metadata[kLogo] = resolveLogo(brand, logoSpec, [
133+
const resolvedLogo = resolveLogo(brand, logoSpec, [
134134
"small",
135135
"medium",
136136
"large",
137137
]);
138+
if (resolvedLogo) {
139+
if (resolvedLogo.light) {
140+
resolvedLogo.light.path = resolvedLogo.light.path.replaceAll(
141+
"\\",
142+
"/",
143+
);
144+
}
145+
if (resolvedLogo.dark) {
146+
resolvedLogo.dark.path = resolvedLogo.dark.path.replaceAll(
147+
"\\",
148+
"/",
149+
);
150+
}
151+
}
152+
format.metadata[kLogo] = resolvedLogo;
138153

139154
const extras: FormatExtras = await baseHtmlFormat.formatExtras(
140155
input,

src/project/types/website/website-navigation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,11 +1516,11 @@ async function sidebarTitle(sidebar: Sidebar, project: ProjectContext) {
15161516
}
15171517

15181518
function resolveLogo(logo?: string) {
1519-
if (logo && !isExternalPath(logo) && !logo.startsWith("/")) {
1520-
return "/" + logo;
1521-
} else {
1522-
return logo;
1519+
if (!logo || isExternalPath(logo)) {
1520+
return logo; // TODO: what about urls on windows? https://github.com/quarto-dev/quarto-cli/issues/12643
15231521
}
1522+
logo = logo.replaceAll("\\", "/"); // windows path to url
1523+
return logo.startsWith("/") ? logo : "/" + logo;
15241524
}
15251525

15261526
async function websiteHeadroom(project: ProjectContext) {

tests/docs/smoke-all/brand/logo/logo-extension/test.qmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ title: test brand extension
33
format:
44
html: default
55
dashboard: default
6-
# ERROR: NotFound: No such file or directory (os error 2): rename
7-
# '/Users/gordon/src/quarto-cli/tests/docs/smoke-all/brand/logo/logo-extension/test.html' ->
8-
# '/Users/gordon/src/quarto-cli/tests/docs/smoke-all/brand/logo/logo-extension/_site/test.html'
9-
# revealjs: default
6+
revealjs: default
107
typst:
118
output-ext: typ
129
_quarto:
@@ -23,6 +20,11 @@ _quarto:
2320
- 'img[src="site_libs/quarto-contrib/quarto-project/my-brand/sun-face.png"][alt="sun face"][class="navbar-logo light-content d-inline-block"]'
2421
- 'img[src="site_libs/quarto-contrib/quarto-project/my-brand/moon-face.png"][alt="moon face"][class="navbar-logo dark-content d-inline-block"]'
2522
- []
23+
revealjs:
24+
ensureHtmlElements:
25+
-
26+
- 'img[src="revealjs-dark-logo.png"][alt="sun face"]'
27+
- []
2628
typst:
2729
ensureTypstFileRegexMatches:
2830
-

0 commit comments

Comments
 (0)