diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index 84563f201ea..7838f4043a2 100644 --- a/news/changelog-1.10.md +++ b/news/changelog-1.10.md @@ -17,6 +17,12 @@ All changes included in 1.10: - ([#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) +## Projects + +### Websites + +- ([#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. + ## Commands ### `quarto preview` diff --git a/src/project/types/website/website-shared.ts b/src/project/types/website/website-shared.ts index 20214ac7125..d762d3a4840 100644 --- a/src/project/types/website/website-shared.ts +++ b/src/project/types/website/website-shared.ts @@ -171,40 +171,26 @@ export async function websiteNavigationConfig(project: ProjectContext) { sidebars[0].tools = []; } - let sideLogo = sidebars[0].logo; - if (sideLogo !== false) { // don't do anything logo processing when sidebar logo is opt-out - if (sideLogo && sidebars[0][kLogoAlt]) { - const alt = sidebars[0][kLogoAlt]; - if (typeof sideLogo === "string") { - sideLogo = { path: sideLogo, alt }; + for (let i = 0; i < sidebars.length; i++) { + const sb = sidebars[i]; + // Secondary sidebars without explicit logo inherit from the first via propagation + if (i > 0 && sb.logo === undefined) continue; + let sideLogo = sb.logo; + if (sideLogo !== false) { // don't do anything logo processing when sidebar logo is opt-out + if (sideLogo && sb[kLogoAlt]) { + const alt = sb[kLogoAlt]; + if (typeof sideLogo === "string") { + sideLogo = { path: sideLogo, alt }; + } } - // possible but absurd - // else if ("path" in sideLogo) { - // sideLogo = { ...sideLogo, alt }; - // } else { - // sideLogo = { - // light: !sideLogo.light ? undefined : typeof sideLogo.light === "string" - // ? { - // path: sideLogo.light, - // alt, - // } - // : { ...sideLogo.light, alt }, - // dark: !sideLogo.dark ? undefined : typeof sideLogo.dark === "string" - // ? { - // path: sideLogo.dark, - // alt, - // } - // : { ...sideLogo.dark, alt }, - // }; - // } + let logo = resolveLogo(projectBrand, sideLogo, [ + "medium", + "small", + "large", + ]); + logo = logoAddLeadingSlashes(logo, projectBrand, undefined); + sb.logo = logo; } - let logo = resolveLogo(projectBrand, sideLogo, [ - "medium", - "small", - "large", - ]); - logo = logoAddLeadingSlashes(logo, projectBrand, undefined); - sidebars[0].logo = logo; } // convert contents: auto into items diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/.gitignore b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/.gitignore new file mode 100644 index 00000000000..ad293093b07 --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/.gitignore @@ -0,0 +1,2 @@ +/.quarto/ +**/*.quarto_ipynb diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_brand.yml b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_brand.yml new file mode 100644 index 00000000000..3013856bb5f --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_brand.yml @@ -0,0 +1,11 @@ +color: + background: + light: "#fff" + dark: "#111" + foreground: + light: "#111" + dark: "#fff" +logo: + medium: + light: sun-face.png + dark: moon-face.png diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_quarto.yml b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_quarto.yml new file mode 100644 index 00000000000..6bbc54c500e --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/_quarto.yml @@ -0,0 +1,16 @@ +project: + type: website +theme: + light: brand + dark: [brand, dark-fixups.scss] +website: + sidebar: + - title: "Group 1" + style: "docked" + contents: + - index.qmd + + - title: "Group 2" + style: "docked" + contents: + - page.qmd diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/dark-fixups.scss b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/dark-fixups.scss new file mode 100644 index 00000000000..4b1e9601a6a --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/dark-fixups.scss @@ -0,0 +1,9 @@ +/*-- scss:rules --*/ + +nav.sidebar.sidebar-navigation:not(.rollup) { + background-color: #282b30; +} + +nav.navbar { + background-color: rgba(13, 108, 251, 25%); +} diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/index.qmd b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/index.qmd new file mode 100644 index 00000000000..04c3d41b79f --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/index.qmd @@ -0,0 +1,13 @@ +--- +title: "Group 1 Page" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'img[class*="light-content"][src="./sun-face.png"]' + - 'img[class*="dark-content"][src="./moon-face.png"]' + - [] +--- + +First sidebar with no explicit logo. Brand logo should be resolved for sidebar 1. diff --git a/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/page.qmd b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/page.qmd new file mode 100644 index 00000000000..1786f4da6ac --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/sidebar/brand-multi-sidebar/page.qmd @@ -0,0 +1,13 @@ +--- +title: "Group 2 Page" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'img[class*="light-content"][src="./sun-face.png"]' + - 'img[class*="dark-content"][src="./moon-face.png"]' + - [] +--- + +Second sidebar with no explicit logo. Brand logo should be inherited from sidebar 1. diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/.gitignore b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/.gitignore new file mode 100644 index 00000000000..ad293093b07 --- /dev/null +++ b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/.gitignore @@ -0,0 +1,2 @@ +/.quarto/ +**/*.quarto_ipynb diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/_quarto.yml b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/_quarto.yml new file mode 100644 index 00000000000..fb273727d3e --- /dev/null +++ b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/_quarto.yml @@ -0,0 +1,29 @@ +project: + type: website + output-dir: _site + +render: + - index.qmd + - page.qmd + - page2.qmd + +website: + title: "Issue 14353" + sidebar: + - title: "Group 1" + logo: /img/logo-a.png + contents: + - index.qmd + + - title: "Group 2" + logo: /img/logo-b.png + contents: + - page.qmd + + - title: "Group 3" + contents: + - page2.qmd + +format: + html: + theme: cosmo diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-a.png b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-a.png new file mode 100644 index 00000000000..70078ff72b4 Binary files /dev/null and b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-a.png differ diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-b.png b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-b.png new file mode 100644 index 00000000000..b1ab5f09f78 Binary files /dev/null and b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/img/logo-b.png differ diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/index.qmd b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/index.qmd new file mode 100644 index 00000000000..9b799ab98cc --- /dev/null +++ b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/index.qmd @@ -0,0 +1,12 @@ +--- +title: "Group 1 Page" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'a.sidebar-logo-link img[src$="logo-a.png"][class*="sidebar-logo"]' + - [] +--- + +This page belongs to the first sidebar entry. Its logo (logo-a.png) should render. diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page.qmd b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page.qmd new file mode 100644 index 00000000000..4417e01b8d3 --- /dev/null +++ b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page.qmd @@ -0,0 +1,12 @@ +--- +title: "Group 2 Page" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'a.sidebar-logo-link img[src$="logo-b.png"][class*="sidebar-logo"]' + - [] +--- + +This page belongs to the second sidebar entry. Its logo (logo-b.png) should render. diff --git a/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page2.qmd b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page2.qmd new file mode 100644 index 00000000000..56e3252d18e --- /dev/null +++ b/tests/docs/smoke-all/website-sidebar/issue-14353-multi-sidebar-logo/page2.qmd @@ -0,0 +1,12 @@ +--- +title: "Group 3 Page" +_quarto: + tests: + html: + ensureHtmlElements: + - + - 'a.sidebar-logo-link img[src$="logo-a.png"][class*="sidebar-logo"]' + - [] +--- + +This page belongs to the third sidebar entry which has no explicit logo. It should inherit logo-a.png from the first sidebar.