Skip to content

brand,revealjs - add support for logo #10967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/format/reveal/format-reveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,33 @@ export function revealjsFormat() {
);
}

const determineRevealLogo = (format: Format): string | undefined => {
const brandData = format.render.brand?.processedData;
if (brandData?.logo) {
// add slide logo if we have one
for (const size of ["medium", "small", "large"]) {
const logoInfo = brandData.logo[size];
if (!logoInfo) {
continue;
}
if (typeof logoInfo === "string") {
return logoInfo;
} else {
// what to do about light vs dark?
return logoInfo.light ?? logoInfo.dark;
}
}
}
};

function revealMarkdownAfterBody(format: Format) {
const lines: string[] = [];
lines.push("::: {.quarto-auto-generated-content style='display: none;'}\n");
if (format.metadata[kSlideLogo]) {
const revealLogo = (format.metadata[kSlideLogo] as (string | undefined)) ??
determineRevealLogo(format);
if (revealLogo) {
lines.push(
`<img src="${format.metadata[kSlideLogo]}" class="slide-logo" />`,
`<img src="${revealLogo}" class="slide-logo" />`,
);
lines.push("\n");
}
Expand Down
2 changes: 2 additions & 0 deletions tests/docs/smoke-all/2024/10/03/logo_reveal/_brand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logo:
large: posit-logo.svg
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2024/10/03/logo_reveal/posit-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions tests/docs/smoke-all/2024/10/03/logo_reveal/revealjs-logo.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
format: revealjs
title: Hello
_quarto:
tests:
revealjs:
ensureHtmlElements:
- ["img.slide-logo"]
- []
---

## Slide

## Another slide
Loading