Skip to content

Commit 4f81806

Browse files
committed
add support for badges on completion
Signed-off-by: Aabid Sofi <[email protected]>
1 parent 4415328 commit 4f81806

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

layouts/partials/badge.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- $b := .badge -}}
2+
{{- $contentId := .curriculaId -}}
3+
{{- $orgId := .orgId | default "" -}}
4+
5+
{{- $svg := cond (partial "is-url.html" $b.svg) $b.svg (partial "banner-url.html" (dict "uuid" $orgId "banner" $b.svg )) -}}
6+
{{- $png := cond (partial "is-url.html" $b.png) $b.png (partial "banner-url.html" (dict "uuid" $orgId "banner" $b.svg )) -}}
7+
8+
{{- $badge := "nil" -}}
9+
10+
{{- if $b }}
11+
{{- $badge = dict
12+
"title" $b.title
13+
"description" $b.description
14+
"label" $contentId
15+
"svg" $svg
16+
"png" $png
17+
-}}
18+
{{- end -}}
19+
20+
21+
{{- return $badge -}}

layouts/partials/is-url.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- $s := . -}}
2+
{{- $isUrl := or (strings.HasPrefix $s "http://") (strings.HasPrefix $s "https://") -}}
3+
{{- return $isUrl -}}

layouts/partials/learning-path.json.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"title": {{ .Title | jsonify }},
2424
"description": {{ .Description | jsonify }},
2525
"banner": {{ $banner_url | jsonify }},
26-
"badge": {{ .Params.badge | jsonify }},
26+
"badge": {{ partial "badge.html" (dict "badge" .Params.badge "curriculaId" $id "orgId" $uuid ) | jsonify }},
2727
"certificate": {{ .Params.certificate | jsonify }},
2828
"permalink": {{ .Permalink | jsonify }},
2929
"categories": {{ .Params.Categories | jsonify }},

0 commit comments

Comments
 (0)