mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-12-22 17:15:07 +01:00
Add 'align' option to figure shortcode (#256)
Usage: {{< figure align=center src="image.jpg" >}} Parameter values: - 'center': align image and captions to center of page - anything else neglected * Appends "#center" to the image's URL in order to utilize existing CSS rules for centering images.
This commit is contained in:
parent
45c4b48e53
commit
14ebcdecf3
@ -242,6 +242,10 @@
|
||||
margin: auto
|
||||
}
|
||||
|
||||
.post-content figure.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.post-content figure > figcaption {
|
||||
color: var(--primary);
|
||||
font-size: 16px;
|
||||
|
@ -1,8 +1,11 @@
|
||||
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
|
||||
<figure{{ if or (.Get "class") (eq (.Get "align") "center") }} class="
|
||||
{{- if eq (.Get "align") "center" }}align-center {{ end }}
|
||||
{{- with .Get "class" }}{{ . }}{{- end }}"
|
||||
{{- end -}}>
|
||||
{{- if .Get "link" -}}
|
||||
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
||||
{{- end }}
|
||||
<img src="{{ .Get "src" }}"
|
||||
<img src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
|
||||
{{- if or (.Get "alt") (.Get "caption") }}
|
||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
||||
{{- end -}}
|
||||
|
Loading…
Reference in New Issue
Block a user