Skip to content

Commit 61bc604

Browse files
normalize sidebar logo
and logo-alt to LightDarkLogo makes me wonder if it is a good idea to have a normalized internal type we will also need to support dark logo and logo-alt in the logo document option
1 parent 297157d commit 61bc604

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ async function sidebarEjsData(project: ProjectContext, sidebar: Sidebar) {
10121012

10131013
// ensure title and search are present
10141014
sidebar.title = await sidebarTitle(sidebar, project) as string | undefined;
1015+
console.log("sidebar.logo", sidebar.logo);
10151016
if (sidebar.logo?.light) {
10161017
sidebar.logo.light.path = resolveLogo(sidebar.logo.light.path)!;
10171018
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ export async function websiteNavigationConfig(project: ProjectContext) {
148148
sidebars[0].tools = [];
149149
}
150150

151+
if (sidebars[0].logo) { // normalize to LightDarkLogo
152+
if (typeof (sidebars[0].logo) === "string") {
153+
sidebars[0].logo = {
154+
light: {
155+
path: sidebars[0].logo,
156+
alt: (sidebars[0] as unknown as { "logo-alt": string })["logo-alt"],
157+
},
158+
};
159+
}
160+
}
161+
151162
// convert contents: auto into items
152163
for (const sb of sidebars) {
153164
if (sb.contents && !Array.isArray(sb.contents)) {

tests/docs/smoke-all/2024/07/09/issue-10251/index.qmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ title: "issue-10251"
33
_quarto:
44
tests:
55
html:
6-
ensureFileRegexMatches:
7-
- [
8-
'<img src="https://quarto.org/quarto.png" alt="this is the alt text that for the logo in the sidebar" class="sidebar-logo py-0 d-lg-inline d-none">',
9-
'<img src="https://quarto.org/quarto.png" alt="this is the alt text that for the logo in the navbar" class="navbar-logo">'
10-
]
6+
ensureHtmlElements:
7+
-
8+
- 'img[src="https://quarto.org/quarto.png"][alt="this is the alt text that for the logo in the sidebar"][class="sidebar-logo light-content py-0 d-lg-inline d-none"]'
9+
- 'img[src="https://quarto.org/quarto.png"][alt="this is the alt text that for the logo in the navbar"][class="navbar-logo"]'
10+
- []
1111
---
1212

1313
This is a Quarto website.

0 commit comments

Comments
 (0)