Skip to content

Commit fc08804

Browse files
optional final brandMode parameter for brand logo shortcode
we still don't resolve light and dark logos properly but at least don't crash here includes brand logo shortcode tests fixes #12564
1 parent 44d25e1 commit fc08804

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

news/changelog-1.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ All changes included in 1.7:
153153
- ([#12326](https://github.com/quarto-dev/quarto-cli/issues/12326)): Add `quarto.shortcode.*` API entry points for shortcode developers.
154154
- ([#12365](https://github.com/quarto-dev/quarto-cli/pull/12365)): `brand color` shortcode takes an optional `brandMode` second parameter, default `light`.
155155
- ([#12453](https://github.com/quarto-dev/quarto-cli/issues/12453)): Expose `_quarto.modules.brand` as `quarto.brand` and add `has_mode()` function.
156+
- ([#12564](https://github.com/quarto-dev/quarto-cli/issues/12564)): `brand logo` shortcode also takes an optional `brandMode` second parameter, default `light`.
156157

157158
### Conditional Content
158159

src/resources/filters/quarto-pre/shortcodes-handlers.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ function initShortcodeHandlers()
128128

129129
if brandCommand == "logo" then
130130
local logo_name = read_arg(args, 2)
131-
local logo_value = brand.get_logo(logo_name)
131+
local brandMode = 'light'
132+
if #args > 2 then
133+
brandMode = read_arg(args, 3) or brandMode
134+
end
135+
local logo_value = brand.get_logo(brandMode, logo_name)
132136
local entry = { path = nil }
133137

134138
if type(logo_value) ~= "table" then
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Test brand light/dark shortcodes
3+
format: html
4+
brand:
5+
light:
6+
logo:
7+
small:
8+
light: sun.png
9+
dark: sun.png
10+
dark:
11+
logo:
12+
small:
13+
light: moon.png
14+
dark: moon.png
15+
_quarto:
16+
tests:
17+
html:
18+
ensureHtmlElements:
19+
-
20+
- 'img[src="moon.png"]'
21+
- []
22+
---
23+
24+
::: {}
25+
26+
{{< brand logo small dark >}}
27+
28+
:::
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Test brand light/dark shortcodes
3+
format: html
4+
brand:
5+
light:
6+
logo:
7+
small:
8+
# light/dark don't work here yet,
9+
# but brand.ts will drop entries that don't have both
10+
light: sun.png
11+
dark: sun.png
12+
dark:
13+
logo:
14+
small:
15+
light: moon.png
16+
dark: moon.png
17+
_quarto:
18+
tests:
19+
html:
20+
ensureHtmlElements:
21+
-
22+
- 'img[src="sun.png"]'
23+
- []
24+
---
25+
26+
::: {}
27+
28+
{{< brand logo small >}}
29+
30+
:::
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Test brand light/dark shortcodes
3+
format: html
4+
brand:
5+
logo:
6+
small:
7+
# light/dark don't work here yet,
8+
# but brand.ts will drop entries that don't have both
9+
light: sun.png
10+
dark: moon.png
11+
_quarto:
12+
tests:
13+
html:
14+
ensureHtmlElements:
15+
-
16+
- 'img[src="sun.png"]'
17+
- []
18+
---
19+
20+
21+
{{< brand logo small >}}
22+

0 commit comments

Comments
 (0)