Skip to content

Commit 73d72e9

Browse files
brand processedData also needs to resolve paths in logo.images
1 parent 23e8b99 commit 73d72e9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/core/brand/brand.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
BrandColorLightDark,
1111
BrandFont,
1212
BrandLogoExplicitResource,
13+
BrandLogoResource,
1314
BrandLogoSingle,
1415
BrandLogoUnified,
1516
BrandNamedLogo,
@@ -143,11 +144,7 @@ export class Brand {
143144
}
144145
}
145146
for (const [key, value] of Object.entries(data.logo?.images ?? {})) {
146-
if (typeof value === "string") {
147-
logo.images[key] = { path: value };
148-
} else {
149-
logo.images[key] = value;
150-
}
147+
logo.images[key] = this.resolvePath(value);
151148
}
152149

153150
return {
@@ -240,11 +237,7 @@ export class Brand {
240237
return fonts ?? [];
241238
}
242239

243-
getLogoResource(name: string): BrandLogoExplicitResource {
244-
const entry = this.data.logo?.images?.[name];
245-
if (!entry) {
246-
return { path: name };
247-
}
240+
resolvePath(entry: BrandLogoResource) {
248241
const pathPrefix = relative(this.projectDir, this.brandDir);
249242
if (typeof entry === "string") {
250243
return { path: join(pathPrefix, entry) };
@@ -255,6 +248,13 @@ export class Brand {
255248
};
256249
}
257250

251+
getLogoResource(name: string): BrandLogoExplicitResource {
252+
const entry = this.data.logo?.images?.[name];
253+
if (!entry) {
254+
return { path: name };
255+
}
256+
return this.resolvePath(entry);
257+
}
258258
getLogo(name: BrandNamedLogo): BrandLogoExplicitResource | undefined {
259259
const entry = this.data.logo?.[name];
260260
if (!entry) {

tests/docs/smoke-all/typst/brand-yaml/logo/relative-path/brand-logo.qmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ _quarto:
1111
typst:
1212
ensureTypstFileRegexMatches:
1313
-
14-
- '#let brand-logo-images = \(\s*large-light: \(\s*path: "resources(/|\\\\)quarto.png"\s*\)\s*\)'
14+
- '#let brand-logo-images = \(\s*large-light: \(\s*path: "brand_yaml(/|\\\\)resources(/|\\\\)quarto.png"\s*\)\s*\)'
1515
- '#let brand-logo = \(\s*large: \(\s*path: "brand_yaml(/|\\\\)resources(/|\\\\)quarto.png"\s*\)\s*\)'
1616
- '#set page\(background: align\(center\+top, box\(inset: 2em, image\("brand_yaml(/|\\\\)resources(/|\\\\)quarto.png", width: 225pt\)\)\)\)'
17+
- '#image\(brand-logo-images\.large-light\.path, alt:"from brand-logo-images"\)'
1718
- []
1819
---
1920

2021
{{< lipsum 4 >}}
2122

23+
```{=typst}
24+
#image(brand-logo-images.large-light.path, alt:"from brand-logo-images")
25+
```

0 commit comments

Comments
 (0)