Skip to content

Commit f9439fb

Browse files
committed
Resolve sidebar logo for all sidebars, not just the first
The logo resolution logic (resolveLogo + logoAddLeadingSlashes) only ran for sidebars[0]. Other sidebars kept raw string logo values, but the EJS template expects { light: { path }, dark: { path } } objects since the dark logo support was added in #12996. This caused empty <a> anchors with no <img> for any sidebar after the first. Loop the resolution over all sidebar entries so each sidebar's logo is properly transformed.
1 parent 23bb687 commit f9439fb

7 files changed

Lines changed: 65 additions & 32 deletions

File tree

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

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -171,40 +171,23 @@ export async function websiteNavigationConfig(project: ProjectContext) {
171171
sidebars[0].tools = [];
172172
}
173173

174-
let sideLogo = sidebars[0].logo;
175-
if (sideLogo !== false) { // don't do anything logo processing when sidebar logo is opt-out
176-
if (sideLogo && sidebars[0][kLogoAlt]) {
177-
const alt = sidebars[0][kLogoAlt];
178-
if (typeof sideLogo === "string") {
179-
sideLogo = { path: sideLogo, alt };
174+
for (const sb of sidebars) {
175+
let sideLogo = sb.logo;
176+
if (sideLogo !== false) { // don't do anything logo processing when sidebar logo is opt-out
177+
if (sideLogo && sb[kLogoAlt]) {
178+
const alt = sb[kLogoAlt];
179+
if (typeof sideLogo === "string") {
180+
sideLogo = { path: sideLogo, alt };
181+
}
180182
}
181-
// possible but absurd
182-
// else if ("path" in sideLogo) {
183-
// sideLogo = { ...sideLogo, alt };
184-
// } else {
185-
// sideLogo = {
186-
// light: !sideLogo.light ? undefined : typeof sideLogo.light === "string"
187-
// ? {
188-
// path: sideLogo.light,
189-
// alt,
190-
// }
191-
// : { ...sideLogo.light, alt },
192-
// dark: !sideLogo.dark ? undefined : typeof sideLogo.dark === "string"
193-
// ? {
194-
// path: sideLogo.dark,
195-
// alt,
196-
// }
197-
// : { ...sideLogo.dark, alt },
198-
// };
199-
// }
183+
let logo = resolveLogo(projectBrand, sideLogo, [
184+
"medium",
185+
"small",
186+
"large",
187+
]);
188+
logo = logoAddLeadingSlashes(logo, projectBrand, undefined);
189+
sb.logo = logo;
200190
}
201-
let logo = resolveLogo(projectBrand, sideLogo, [
202-
"medium",
203-
"small",
204-
"large",
205-
]);
206-
logo = logoAddLeadingSlashes(logo, projectBrand, undefined);
207-
sidebars[0].logo = logo;
208191
}
209192

210193
// convert contents: auto into items
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
**/*.quarto_ipynb
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
project:
2+
type: website
3+
output-dir: _site
4+
5+
render:
6+
- index.qmd
7+
- page.qmd
8+
9+
website:
10+
title: "Issue 14353"
11+
sidebar:
12+
- title: "Group 1"
13+
logo: /img/logo-a.png
14+
contents:
15+
- index.qmd
16+
17+
- title: "Group 2"
18+
logo: /img/logo-b.png
19+
contents:
20+
- page.qmd
21+
22+
format:
23+
html:
24+
theme: cosmo
76 Bytes
Loading
75 Bytes
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "Group 1 Page"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'a.sidebar-logo-link img[src$="logo-a.png"][class*="sidebar-logo"]'
9+
- []
10+
---
11+
12+
This page belongs to the first sidebar entry. Its logo (logo-a.png) should render.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "Group 2 Page"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'a.sidebar-logo-link img[src$="logo-b.png"][class*="sidebar-logo"]'
9+
- []
10+
---
11+
12+
This page belongs to the second sidebar entry. Its logo (logo-b.png) should render.

0 commit comments

Comments
 (0)