Skip to content

Commit e67f988

Browse files
prefix project-resolved logo paths with slash
fixes #11982 this was already done for navbar and sidebar the commit moves that logic up to Brand itself this breaks a huge number of tests; pushing to CI to gauge the damage
1 parent ff0f110 commit e67f988

File tree

3 files changed

+7
-33
lines changed

3 files changed

+7
-33
lines changed

src/core/brand/brand.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,15 @@ export class Brand {
245245
resolvePath(entry: BrandLogoResource) {
246246
const pathPrefix = relative(this.projectDir, this.brandDir);
247247
if (typeof entry === "string") {
248-
return { path: isExternalPath(entry) ? entry : join(pathPrefix, entry) };
248+
return {
249+
path: isExternalPath(entry) ? entry : "/" + join(pathPrefix, entry),
250+
};
249251
}
250252
return {
251253
...entry,
252254
path: isExternalPath(entry.path)
253255
? entry.path
254-
: join(pathPrefix, entry.path),
256+
: "/" + join(pathPrefix, entry.path),
255257
};
256258
}
257259

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,16 +1015,6 @@ async function sidebarEjsData(project: ProjectContext, sidebar: Sidebar) {
10151015

10161016
// ensure title and search are present
10171017
sidebar.title = await sidebarTitle(sidebar, project) as string | undefined;
1018-
if (sidebar.logo) {
1019-
// sidebar logo has been normalized
1020-
const sidebarLogo = sidebar.logo as NormalizedLogoLightDarkSpecifier;
1021-
if (sidebarLogo.light) {
1022-
sidebarLogo.light.path = resolveLogo(sidebarLogo.light.path)!;
1023-
}
1024-
if (sidebarLogo.dark) {
1025-
sidebarLogo.dark.path = resolveLogo(sidebarLogo.dark.path)!;
1026-
}
1027-
}
10281018
const searchOpts = await searchOptions(project);
10291019
sidebar.search = sidebar.search !== undefined
10301020
? sidebar.search
@@ -1258,16 +1248,6 @@ async function navbarEjsData(
12581248
: ("-" + (navbar[kCollapseBelow] || "lg")) as LayoutBreak,
12591249
pinned: navbar.pinned !== undefined ? !!navbar.pinned : false,
12601250
};
1261-
if (data.logo) {
1262-
// navbar logo has been normalized
1263-
const navbarLogo = data.logo as NormalizedLogoLightDarkSpecifier;
1264-
if (navbarLogo.light) {
1265-
navbarLogo.light.path = resolveLogo(navbarLogo.light.path)!;
1266-
}
1267-
if (navbarLogo.dark) {
1268-
navbarLogo.dark.path = resolveLogo(navbarLogo.dark.path)!;
1269-
}
1270-
}
12711251
// if there is no navbar title and it hasn't been set to 'false'
12721252
// then use the site title
12731253
if (!data.title && data.title !== false) {
@@ -1515,14 +1495,6 @@ async function sidebarTitle(sidebar: Sidebar, project: ProjectContext) {
15151495
}
15161496
}
15171497

1518-
function resolveLogo(logo?: string) {
1519-
if (logo && !isExternalPath(logo) && !logo.startsWith("/")) {
1520-
return "/" + logo;
1521-
} else {
1522-
return logo;
1523-
}
1524-
}
1525-
15261498
async function websiteHeadroom(project: ProjectContext) {
15271499
const { navbar, sidebars } = await websiteNavigationConfig(project);
15281500
if (navbar || sidebars?.length) {

tests/docs/smoke-all/brand/logo/choose-logo-resource.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ _quarto:
2222
dashboard:
2323
ensureHtmlElements:
2424
-
25-
- 'img[src="posit-logo-2024.svg"][alt="posit logo"]'
25+
- 'img[src="/posit-logo-2024.svg"][alt="posit logo"]'
2626
- []
2727
revealjs:
2828
ensureHtmlElements:
2929
-
30-
- 'img[src="posit-logo-2024.svg"][class="slide-logo"]'
30+
- 'img[src="/posit-logo-2024.svg"][class="slide-logo"]'
3131
- []
3232
typst:
3333
ensureTypstFileRegexMatches:
3434
-
35-
- 'background: align\(left\+top, box\(inset: 0.75in, image\("posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
35+
- 'background: align\(left\+top, box\(inset: 0.75in, image\("/posit-logo-2024.svg", width: 1\.5in, alt: "posit logo"\)\)'
3636
- []
3737
---
3838

0 commit comments

Comments
 (0)