Skip to content

Commit 6910d64

Browse files
authored
Fix sidebar logo not displaying for non-first sidebars
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 dark logo support was added in v1.8.15. This caused empty logo anchor elements with no <img> for any sidebar after the first. - Loop logo resolution over all sidebar entries with an explicit logo - Sidebars without a logo key still inherit via propagation spread - Sidebars with logo: false still opt out correctly - Preserve brand logo resolution order for the first sidebar Closes #14353, closes #13565
1 parent 896ffea commit 6910d64

15 files changed

Lines changed: 155 additions & 32 deletions

File tree

news/changelog-1.10.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ All changes included in 1.10:
1717

1818
- ([#14354](https://github.com/quarto-dev/quarto-cli/pull/14354)): Fix trailing whitespace after author name on title slide when ORCID is not set. (author: @jnkatz)
1919

20+
## Projects
21+
22+
### Websites
23+
24+
- ([#13565](https://github.com/quarto-dev/quarto-cli/issues/13565), [#14353](https://github.com/quarto-dev/quarto-cli/issues/14353)): Fix sidebar logo not appearing on secondary sidebars in multi-sidebar website layouts.
25+
2026
## Commands
2127

2228
### `quarto preview`

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

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -171,40 +171,26 @@ 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 (let i = 0; i < sidebars.length; i++) {
175+
const sb = sidebars[i];
176+
// Secondary sidebars without explicit logo inherit from the first via propagation
177+
if (i > 0 && sb.logo === undefined) continue;
178+
let sideLogo = sb.logo;
179+
if (sideLogo !== false) { // don't do anything logo processing when sidebar logo is opt-out
180+
if (sideLogo && sb[kLogoAlt]) {
181+
const alt = sb[kLogoAlt];
182+
if (typeof sideLogo === "string") {
183+
sideLogo = { path: sideLogo, alt };
184+
}
180185
}
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-
// }
186+
let logo = resolveLogo(projectBrand, sideLogo, [
187+
"medium",
188+
"small",
189+
"large",
190+
]);
191+
logo = logoAddLeadingSlashes(logo, projectBrand, undefined);
192+
sb.logo = logo;
200193
}
201-
let logo = resolveLogo(projectBrand, sideLogo, [
202-
"medium",
203-
"small",
204-
"large",
205-
]);
206-
logo = logoAddLeadingSlashes(logo, projectBrand, undefined);
207-
sidebars[0].logo = logo;
208194
}
209195

210196
// 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
color:
2+
background:
3+
light: "#fff"
4+
dark: "#111"
5+
foreground:
6+
light: "#111"
7+
dark: "#fff"
8+
logo:
9+
medium:
10+
light: sun-face.png
11+
dark: moon-face.png
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
project:
2+
type: website
3+
theme:
4+
light: brand
5+
dark: [brand, dark-fixups.scss]
6+
website:
7+
sidebar:
8+
- title: "Group 1"
9+
style: "docked"
10+
contents:
11+
- index.qmd
12+
13+
- title: "Group 2"
14+
style: "docked"
15+
contents:
16+
- page.qmd
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*-- scss:rules --*/
2+
3+
nav.sidebar.sidebar-navigation:not(.rollup) {
4+
background-color: #282b30;
5+
}
6+
7+
nav.navbar {
8+
background-color: rgba(13, 108, 251, 25%);
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Group 1 Page"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'img[class*="light-content"][src="./sun-face.png"]'
9+
- 'img[class*="dark-content"][src="./moon-face.png"]'
10+
- []
11+
---
12+
13+
First sidebar with no explicit logo. Brand logo should be resolved for sidebar 1.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Group 2 Page"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'img[class*="light-content"][src="./sun-face.png"]'
9+
- 'img[class*="dark-content"][src="./moon-face.png"]'
10+
- []
11+
---
12+
13+
Second sidebar with no explicit logo. Brand logo should be inherited from sidebar 1.
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
project:
2+
type: website
3+
output-dir: _site
4+
5+
render:
6+
- index.qmd
7+
- page.qmd
8+
- page2.qmd
9+
10+
website:
11+
title: "Issue 14353"
12+
sidebar:
13+
- title: "Group 1"
14+
logo: /img/logo-a.png
15+
contents:
16+
- index.qmd
17+
18+
- title: "Group 2"
19+
logo: /img/logo-b.png
20+
contents:
21+
- page.qmd
22+
23+
- title: "Group 3"
24+
contents:
25+
- page2.qmd
26+
27+
format:
28+
html:
29+
theme: cosmo

0 commit comments

Comments
 (0)