diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index 728b9340dee..95bc2c66df2 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -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 diff --git a/src/core/brand/brand.ts b/src/core/brand/brand.ts index 1415705afad..226fb8a42c2 100644 --- a/src/core/brand/brand.ts +++ b/src/core/brand/brand.ts @@ -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; } } diff --git a/src/resources/filters/quarto-pre/shortcodes-handlers.lua b/src/resources/filters/quarto-pre/shortcodes-handlers.lua index 2259f089a94..b8f33eb2c09 100644 --- a/src/resources/filters/quarto-pre/shortcodes-handlers.lua +++ b/src/resources/filters/quarto-pre/shortcodes-handlers.lua @@ -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 diff --git a/tests/docs/shortcodes/brand-logo-dark.qmd b/tests/docs/shortcodes/brand-logo-dark.qmd new file mode 100644 index 00000000000..52c8cbed60b --- /dev/null +++ b/tests/docs/shortcodes/brand-logo-dark.qmd @@ -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 >}} + +::: \ No newline at end of file diff --git a/tests/docs/shortcodes/brand-logo-light.qmd b/tests/docs/shortcodes/brand-logo-light.qmd new file mode 100644 index 00000000000..821b5b20ec7 --- /dev/null +++ b/tests/docs/shortcodes/brand-logo-light.qmd @@ -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 >}} + +::: \ No newline at end of file diff --git a/tests/docs/shortcodes/brand-logo-one-brand.qmd b/tests/docs/shortcodes/brand-logo-one-brand.qmd new file mode 100644 index 00000000000..b5821587aa4 --- /dev/null +++ b/tests/docs/shortcodes/brand-logo-one-brand.qmd @@ -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 >}} +