Skip to content

Commit 15b4845

Browse files
authored
Merge pull request #13507 from quarto-dev/fix/nologo-sidebar
2 parents c870167 + b289945 commit 15b4845

File tree

8 files changed

+79
-4
lines changed

8 files changed

+79
-4
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All changes included in 1.9:
55
- ([#13396](https://github.com/quarto-dev/quarto-cli/issues/13396)): Fix `quarto publish connect` regression.
66
- ([#13441](https://github.com/quarto-dev/quarto-cli/pull/13441)): Catch `undefined` exceptions in Pandoc failure to avoid spurious error message.
77
- ([#13046](https://github.com/quarto-dev/quarto-cli/issues/13046)): Use new url for multiplex socket.io server <https://multiplex.up.railway.app/> as default for `format: revealjs` and `revealjs.multiplex: true`.
8+
- ([#13506](https://github.com/quarto-dev/quarto-cli/issues/13506)): Fix navbar active state detection when sidebar has no logo configured. Prevents empty logo links from interfering with navigation highlighting.
89

910
## Dependencies
1011

src/core/brand/brand.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,14 @@ export function resolveLogo(
344344
return logo;
345345
};
346346
if (!spec) {
347+
const lightLogo = findLogo("light", order);
348+
const darkLogo = findLogo("dark", order);
349+
if (!lightLogo && !darkLogo) {
350+
return undefined;
351+
}
347352
return {
348-
light: findLogo("light", order) || findLogo("dark", order),
349-
dark: findLogo("dark", order) || findLogo("light", order),
353+
light: lightLogo || darkLogo,
354+
dark: darkLogo || lightLogo,
350355
};
351356
}
352357
if (typeof spec === "string") {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ function navigationHtmlPostprocessor(
559559
const navLinkHref = navLink.getAttribute("href");
560560

561561
const sidebarLink = doc.querySelector(
562-
'.sidebar-navigation a[href="' + navLinkHref + '"]',
562+
'.sidebar-navigation a[href="' + navLinkHref +
563+
'"]:not(.sidebar-logo-link)',
563564
);
564565
// if the link is either for the current window href or appears on the
565566
// sidebar then set it to active

src/resources/filters/quarto-post/typst-brand-yaml.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function render_typst_brand_yaml()
251251
end
252252
-- logo
253253
local logo = param('logo')
254-
if not next(logo) then
254+
if logo and not next(logo) then
255255
meta.logo = nil
256256
end
257257
local logoOptions = {}
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Issue 13506 - No Logo"
6+
navbar:
7+
left:
8+
- text: "Section A"
9+
href: index.qmd
10+
- text: "Section B"
11+
href: page2.qmd
12+
sidebar:
13+
- title: "Section A"
14+
contents:
15+
- index.qmd
16+
- title: "Section B"
17+
contents:
18+
- page2.qmd
19+
20+
format:
21+
html:
22+
theme: cosmo
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Section A"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'nav.navbar a.nav-link[href$="index.html"].active'
9+
- 'nav.navbar a.nav-link[href$="page2.html"]:not(.active)'
10+
-
11+
- 'a.sidebar-logo-link'
12+
---
13+
14+
## Section A
15+
16+
This is Section A. When NO logo is configured in the sidebar, the navbar active
17+
state should work correctly. The "Section A" navbar item should be active on this page.
18+
19+
The bug (issue #13506): After PR #12996, `sidebar.logo` was normalized to
20+
`{light: undefined, dark: undefined}`, making `if(sidebar.logo)` always true.
21+
This created empty `<a class="sidebar-logo-link">` elements that interfered with
22+
the navbar active state detection logic.
23+
24+
See also: [Section B](page2.qmd)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: "Section B"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'nav.navbar a.nav-link[href$="page2.html"].active'
9+
- 'nav.navbar a.nav-link[href$="index.html"]:not(.active)'
10+
-
11+
- 'a.sidebar-logo-link'
12+
---
13+
14+
## Section B
15+
16+
This is Section B. The "Section B" navbar item should be active on this page,
17+
demonstrating that the navbar active state detection works correctly without
18+
empty logo links interfering.
19+
20+
See also: [Section A](index.qmd)

0 commit comments

Comments
 (0)