Skip to content

Commit 5d1bb1e

Browse files
implement brand yml for dashboard
allowing logo override with path or resource name also allowing logo object with path containing one of those and opt alt text
1 parent f38a78d commit 5d1bb1e

File tree

9 files changed

+215
-0
lines changed

9 files changed

+215
-0
lines changed

src/resources/filters/quarto-post/dashboard.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,44 @@ function render_dashboard()
737737
return doc
738738
end
739739
end
740+
}, {
741+
-- todo: dark mode
742+
Meta = function(meta)
743+
local logo = meta.logo
744+
local resolved
745+
if logo then
746+
local which
747+
if pandoc.utils.type(logo) == 'Inlines' then
748+
which = logo[1].text
749+
local brandLogo = _quarto.modules.brand.get_logo(logo[1].text)
750+
resolved = brandLogo and brandLogo.light
751+
elseif type(logo) == 'table' then
752+
local brandLogo = _quarto.modules.brand.get_logo(logo.path[1].text)
753+
if brandLogo then
754+
resolved = brandLogo.light
755+
if logo.alt then
756+
resolved.alt = logo.alt
757+
end
758+
else
759+
resolved = {
760+
path = logo.path,
761+
alt = logo.alt
762+
}
763+
end
764+
end
765+
else
766+
logo = _quarto.modules.brand.get_logo('small')
767+
or _quarto.modules.brand.get_logo('medium')
768+
or _quarto.modules.brand.get_logo('large')
769+
resolved = logo and logo.light
770+
end
771+
if resolved then
772+
meta.logo = resolved.path
773+
meta['logo-alt'] = resolved.alt
774+
end
775+
776+
return meta
777+
end
740778
}
741779
}
742780
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
logo: large
17+
_quarto:
18+
tests:
19+
dashboard:
20+
ensureFileRegexMatches:
21+
-
22+
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
23+
- []
24+
---
25+
26+
{{< lipsum 4 >}}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
_quarto:
17+
tests:
18+
dashboard:
19+
ensureFileRegexMatches:
20+
-
21+
- '<img src="quarto\.png" alt="quarto logo"'
22+
- []
23+
---
24+
25+
{{< lipsum 4 >}}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
logo:
17+
path: posit-logo-2024.svg
18+
alt: posit logo
19+
_quarto:
20+
tests:
21+
dashboard:
22+
ensureFileRegexMatches:
23+
-
24+
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
25+
- []
26+
---
27+
28+
{{< lipsum 4 >}}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
logo: posit-logo-2024.svg
17+
_quarto:
18+
tests:
19+
dashboard:
20+
ensureFileRegexMatches:
21+
-
22+
- '<img src="posit-logo-2024\.svg" alt=""'
23+
- []
24+
---
25+
26+
{{< lipsum 4 >}}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
logo:
17+
path: large
18+
alt: logo of posit
19+
_quarto:
20+
tests:
21+
dashboard:
22+
ensureFileRegexMatches:
23+
-
24+
- '<img src="posit-logo-2024\.svg" alt="logo of posit"'
25+
- []
26+
---
27+
28+
{{< lipsum 4 >}}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: brand and base logo
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium: quarto
15+
large: posit
16+
logo:
17+
path: large
18+
_quarto:
19+
tests:
20+
dashboard:
21+
ensureFileRegexMatches:
22+
-
23+
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
24+
- []
25+
---
26+
27+
{{< lipsum 4 >}}
Lines changed: 17 additions & 0 deletions
Loading
11.5 KB
Loading

0 commit comments

Comments
 (0)