Skip to content

Commit

Permalink
revealjs allow base logo to specify brand resource
Browse files Browse the repository at this point in the history
or object containing path or resource name
  • Loading branch information
gordonwoodhull committed Nov 15, 2024
1 parent 5d1bb1e commit 6b2db81
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/format/reveal/format-reveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,25 @@ const determineRevealLogo = (format: Format): string | undefined => {
function revealMarkdownAfterBody(format: Format) {
const lines: string[] = [];
lines.push("::: {.quarto-auto-generated-content style='display: none;'}\n");
const revealLogo = (format.metadata[kSlideLogo] as (string | undefined)) ??
determineRevealLogo(format);
let revealLogo = format
.metadata[kSlideLogo] as (string | { path: string } | undefined);
if (revealLogo) {
if (typeof revealLogo === "object") {
revealLogo = revealLogo.path;
}
if (["small", "medium", "large"].includes(revealLogo)) {
const brandData = format.render.brand?.processedData;
const logoInfo = brandData?.logo
?.[revealLogo as ("medium" | "small" | "large")];
if (typeof logoInfo === "string") {
revealLogo = logoInfo;
} else {
revealLogo = logoInfo?.light.path ?? logoInfo?.dark.path;
}
}
} else {
revealLogo = determineRevealLogo(format);
}
if (revealLogo) {
lines.push(
`<img src="${revealLogo}" class="slide-logo" />`,
Expand Down
5 changes: 5 additions & 0 deletions tests/docs/smoke-all/brand/logo/choose-logo-resource.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ _quarto:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
6 changes: 6 additions & 0 deletions tests/docs/smoke-all/brand/logo/default-logo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: brand and base logo
format:
dashboard: default
revealjs: default
brand:
logo:
images:
Expand All @@ -20,6 +21,11 @@ _quarto:
-
- '<img src="quarto\.png" alt="quarto logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="quarto\.png" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
5 changes: 5 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-path-alt.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ _quarto:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
6 changes: 6 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-path.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: brand and base logo
format:
dashboard: default
revealjs: default
brand:
logo:
images:
Expand All @@ -21,6 +22,11 @@ _quarto:
-
- '<img src="posit-logo-2024\.svg" alt=""'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
5 changes: 5 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-resource.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ _quarto:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}

0 comments on commit 6b2db81

Please sign in to comment.