From f0e8a353183d2e47c473311213c4ae9cceb1cdfa Mon Sep 17 00:00:00 2001 From: Nicolas Martignoni Date: Sat, 2 Mar 2019 20:00:27 +0100 Subject: [PATCH] Add test to load CSS only once --- layouts/shortcodes/notice.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/notice.html b/layouts/shortcodes/notice.html index e4a8c8e..be729aa 100644 --- a/layouts/shortcodes/notice.html +++ b/layouts/shortcodes/notice.html @@ -1,7 +1,11 @@ -{{- $noticeType := .Get 0 -}} {{/* Available notice types: warning, info, note, tip */}} +{{- $noticeType := .Get 0 -}} +{{/* Count how many times we've called this shortcode and load the css if it's the first time */}} +{{- if not ($.Page.Scratch.Get "noticecount") -}} +{{- end -}} +{{- $.Page.Scratch.Add "noticecount" 1 -}}
-

{{ i18n $noticeType }}

+

{{- i18n $noticeType -}}

{{- .Inner -}}