1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| <!--https://github.com/martignoni/hugo-notice-->
<!--change notice color-->
{{- $noticeType := .Get 0 -}}
{{- $raw := (markdownify .Inner | chomp) -}}
{{- $block := findRE "(?is)^<(?:address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h(?:1|2|3|4|5|6)|header|hgroup|hr|li|main|nav|noscript|ol|output|p|pre|section|table|tfoot|ul|video)\\b" $raw 1 -}}
{{- if not ($.Page.Scratch.Get "noticeCount") -}}
<style type="text/css">
.notice-icon {
margin: 0 0.5em 0.3em 0;
}
.notice {
padding: 1em;
margin-bottom: 1em;
border-radius: 4px;
}
.notice p:last-child {
margin-bottom: 0;
}
.notice-title {
margin: -1em -1em 0.75em !important;
padding: 0.25em 1em;
border-radius: 4px 4px 0 0;
font-weight: 700;
color: hsl(0, 0%, 100%);
}
[data-theme="dark"] .notice-title {
color: hsl(0, 0%, 75%);
}
.notice.notice-warning .notice-title {
background: hsl(0, 65%, 65%);
}
[data-theme="dark"] .notice.notice-warning .notice-title {
background: hsl(0, 25%, 35%);
}
.notice.notice-warning {
background: hsl(0, 65%, 65%, 0.15);
}
[data-theme="dark"] .notice.notice-warning {
background: hsl(0, 25%, 35%, 0.15);
}
.notice.notice-info .notice-title {
background: hsl(30, 80%, 70%);
}
[data-theme="dark"] .notice.notice-info .notice-title {
background: hsl(30, 25%, 35%);
}
.notice.notice-info {
background: hsl(30, 80%, 70%, 0.15);
}
[data-theme="dark"] .notice.notice-info {
background: hsl(30, 25%, 35%, 0.15);
}
.notice.notice-note .notice-title {
background: hsl(200, 65%, 65%);
}
[data-theme="dark"] .notice.notice-note .notice-title {
background: hsl(200, 25%, 35%);
}
.notice.notice-note {
background: hsl(200, 65%, 65%, 0.15);
}
[data-theme="dark"] .notice.notice-note {
background: hsl(200, 25%, 35%, 0.15);
}
.notice.notice-tip .notice-title {
background: hsl(140, 65%, 65%);
}
[data-theme="dark"] .notice.notice-tip .notice-title {
background: hsl(140, 25%, 35%);
}
.notice.notice-tip {
background: hsl(140, 65%, 65%, 0.15);
}
[data-theme="dark"] .notice.notice-tip {
background: hsl(140, 25%, 35%, 0.15);
}
</style>
{{- end -}}
{{- $.Page.Scratch.Add "noticeCount" 1 -}}
{{ $icon := (replace (index $.Site.Data.SVG $noticeType) "icon" "icon notice-icon") }}
<div class="notice {{ $noticeType }}" {{ if len .Params | eq 2 }} id="{{ .Get 1 }}" {{ end }}>
<p class="first notice-title">{{ $icon | safeHTML }}{{- i18n $noticeType -}}</p>
{{- if or $block (not $raw) }}{{ $raw }}{{ else }}<p>{{ $raw }}</p>{{ end -}}
</div>
|