Skip to content

Commit 024a6a6

Browse files
authored
fix: fix SVG css (#55)
1 parent b8f3cd5 commit 024a6a6

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

assets/css/docs-nginx-com/style.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,18 @@ section {
186186
display: block
187187
}
188188

189-
figure {
189+
.figure-bitmap {
190190
border: solid 2px #42932D;
191191
margin-bottom: 10px;
192192
display: inline-block;
193193
max-width: 100%;
194-
max-height: 100%
194+
}
195+
196+
.figure-svg {
197+
border: solid 2px #42932D;
198+
margin-bottom: 10px;
199+
display: block;
200+
min-width: 100%;
195201
}
196202

197203
caption,

layouts/shortcodes/img.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
2-
{{- if .Get "link" -}}
3-
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
4-
{{- end }}
5-
<img src="{{ .Get "src" | relURL }}"
6-
{{- if or (.Get "alt") (.Get "caption") }}
7-
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
8-
{{- end -}}
9-
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
10-
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
11-
/> <!-- Closing img tag -->
2+
{{- $src := .Get "src" -}}
3+
{{- $isSVG := strings.HasSuffix $src ".svg" -}}
4+
<img class="{{ if $isSVG }}figure-svg{{ else }}figure-bitmap{{ end }}" src="{{ .Get "src" | relURL }}"
5+
{{- if or (.Get "alt") (.Get "caption") }}
6+
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
7+
{{- end -}}
8+
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
9+
{{- with .Get "height" }} height="{{ . }}"{{ end -}}>
10+
{{- if and (.Get "link") $isSVG }}
11+
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
12+
{{- end -}}
1213
{{- if .Get "link" }}</a>{{ end -}}
1314
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
1415
<figcaption>

0 commit comments

Comments
 (0)