diff --git a/exampleSite/content/en/blog/bootstrap-elements.md b/exampleSite/content/en/blog/bootstrap-elements.md index 2530946a..1233de84 100644 --- a/exampleSite/content/en/blog/bootstrap-elements.md +++ b/exampleSite/content/en/blog/bootstrap-elements.md @@ -49,15 +49,26 @@ As an example, the following shortcode displays a simple alert. ## Badge -Use HTML code to display a badge for a heading. See the Bootstrap [documentation]({{< param "links.bs_badge_heading" >}}) for more options. +Use the badge shortcode to display a badge for a heading. {{< example >}} -

Example heading of size one New

-

Example heading of size two New

-

Example heading of size three New

-

Example heading of size four New

-
Example heading of size five New
-
Example heading of size six New
+Heading 1 {{}} +{.h1} + +Heading 2 {{}} +{.h2} + +Heading 3 {{}} +{.h3} + +Heading 4 {{}} +{.h4} + +Heading 5 {{}} +{.h5} + +Heading 6 {{}} +{.h6} {{< /example >}} ## Breadcrumb diff --git a/layouts/shortcodes/badge.html b/layouts/shortcodes/badge.html new file mode 100644 index 00000000..16f10730 --- /dev/null +++ b/layouts/shortcodes/badge.html @@ -0,0 +1,23 @@ + + +{{- $error := false -}} +{{- $title := .Get "title" -}} +{{- $class := .Get "class" -}} +{{- $color := "secondary" -}} +{{- with .Get "color" }}{{ $color = . }}{{ end -}} +{{- $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "white" "black" -}} +{{- if not (in $supportedColors $color) -}} + {{- errorf "Invalid value for param 'color': %s" .Position -}} +{{- end -}} + +{{- if not $title }} + {{ errorf "Missing title: %s" .Position -}} +{{ else -}} + {{ $title | plainify }} +{{ end -}}