Skip to content
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
1 change: 1 addition & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ All changes included in 1.7:
- ([#12326](https://github.com/quarto-dev/quarto-cli/issues/12326)): Add `quarto.shortcode.*` API entry points for shortcode developers.
- ([#12365](https://github.com/quarto-dev/quarto-cli/pull/12365)): `brand color` shortcode takes an optional `brandMode` second parameter, default `light`.
- ([#12453](https://github.com/quarto-dev/quarto-cli/issues/12453)): Expose `_quarto.modules.brand` as `quarto.brand` and add `has_mode()` function.
- ([#12564](https://github.com/quarto-dev/quarto-cli/issues/12564)): `brand logo` shortcode also takes an optional `brandMode` second parameter, default `light`.

### Conditional Content

Expand Down
12 changes: 6 additions & 6 deletions src/core/brand/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export class Brand {
if (v) {
logo[size] = v;
}
for (const [key, value] of Object.entries(data.logo?.images ?? {})) {
if (typeof value === "string") {
logo.images[key] = { path: value };
} else {
logo.images[key] = value;
}
}
for (const [key, value] of Object.entries(data.logo?.images ?? {})) {
if (typeof value === "string") {
logo.images[key] = { path: value };
} else {
logo.images[key] = value;
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/resources/filters/quarto-pre/shortcodes-handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ function initShortcodeHandlers()

if brandCommand == "logo" then
local logo_name = read_arg(args, 2)
local logo_value = brand.get_logo(logo_name)
local brandMode = 'light'
if #args > 2 then
brandMode = read_arg(args, 3) or brandMode
end
local logo_value = brand.get_logo(brandMode, logo_name)
local entry = { path = nil }

if type(logo_value) ~= "table" then
Expand Down
28 changes: 28 additions & 0 deletions tests/docs/shortcodes/brand-logo-dark.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Test brand light/dark shortcodes
format: html
brand:
light:
logo:
small:
light: sun.png
dark: sun.png
dark:
logo:
small:
light: moon.png
dark: moon.png
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'img[src="moon.png"]'
- []
---

::: {}

{{< brand logo small dark >}}

:::
30 changes: 30 additions & 0 deletions tests/docs/shortcodes/brand-logo-light.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Test brand light/dark shortcodes
format: html
brand:
light:
logo:
small:
# light/dark don't work here yet,
# but brand.ts will drop entries that don't have both
light: sun.png
dark: sun.png
dark:
logo:
small:
light: moon.png
dark: moon.png
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'img[src="sun.png"]'
- []
---

::: {}

{{< brand logo small >}}

:::
22 changes: 22 additions & 0 deletions tests/docs/shortcodes/brand-logo-one-brand.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Test brand light/dark shortcodes
format: html
brand:
logo:
small:
# light/dark don't work here yet,
# but brand.ts will drop entries that don't have both
light: sun.png
dark: moon.png
_quarto:
tests:
html:
ensureHtmlElements:
-
- 'img[src="sun.png"]'
- []
---


{{< brand logo small >}}

Loading