Detecting the use of shortcodes

layouts/shortcodes/alert.html

{{- $color := .Get "color" }}
{{- $content := .Inner | markdownify }}
{{- .Page.Store.SetInMap "alerts" (printf "alert_%d" .Ordinal) (dict "color" $color "content" $content) }}
<p style="color: {{ $color }}">{{ $content }}</p>

layouts/partials/head.html

{{- $noop := .Content }}
{{- range .Store.GetSortedMapValues "alerts" }}
<h1 style="color:{{ .color }}">{{ .content }}</h1>
{{- end }}
3 Likes