mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 16:15:12 +00:00
figure shortcode: Support i18n and unnumbered captions
- Figures are now unnumbered by default
- To number a figure, use the form:
- `{{< figure src="image.jpg" title="Caption" numbered="true" >}}`
- Add i18n translation for "Figure" in captions
- Update English and Chinese language packs
Close #328 and #513
This commit is contained in:
1 parent
9fa9d56eb3
commit
f23526e55d
4 files changed
+38
-6
No files matched your search
@@ -20,6 +20,9 @@
|
||||
- id: next
|
||||
translation: Next
|
||||
|
||||
- id: figure
|
||||
translation: "Figure %d:"
|
||||
|
||||
# Buttons
|
||||
|
||||
- id: btn_preprint
|
||||
|
||||
@@ -14,6 +14,15 @@
|
||||
- id: minute_read
|
||||
translation: 分钟阅读时间
|
||||
|
||||
- id: previous
|
||||
translation: 上一页
|
||||
|
||||
- id: next
|
||||
translation: 下一页
|
||||
|
||||
- id: figure
|
||||
translation: "图%d:"
|
||||
|
||||
# Buttons
|
||||
|
||||
- id: btn_preprint
|
||||
|
||||
@@ -139,12 +139,6 @@ video {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
figcaption:before {
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
content: "Figure " counter(captions) ": ";
|
||||
}
|
||||
|
||||
figcaption {
|
||||
display: block;
|
||||
margin-top: 0.75em;
|
||||
@@ -152,6 +146,15 @@ figcaption {
|
||||
font-size: 1rem;
|
||||
margin-bottom: 1.65rem;
|
||||
font-family: '{{ .Get "heading_font" }}', sans-serif;
|
||||
}
|
||||
|
||||
figcaption.numbered:before {
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
content: attr(data-pre) counter(captions) attr(data-post);
|
||||
}
|
||||
|
||||
figcaption.numbered {
|
||||
counter-increment: captions;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<figure{{ with .Get "class" }} class="{{.}}"{{ end }}>
|
||||
{{ if .Get "link"}}<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{ end }}
|
||||
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}{{ with .Get "height" }}height="{{.}}" {{ end }}/>
|
||||
{{ if .Get "link"}}</a>{{ end }}
|
||||
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
|
||||
{{ $figure := split (i18n "figure" | default "Figure %d:") "%d" }}
|
||||
<figcaption data-pre="{{ index $figure 0 }}" data-post="{{ index $figure 1 }}" {{ if eq (.Get "numbered") "true" }}class="numbered"{{ end }}>{{ if isset .Params "title" }}
|
||||
<h4>{{ .Get "title" }}</h4>{{ end }}
|
||||
{{ if or (.Get "caption") (.Get "attr")}}<p>
|
||||
{{ .Get "caption" }}
|
||||
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
|
||||
{{ .Get "attr" }}
|
||||
{{ if .Get "attrlink"}}</a> {{ end }}
|
||||
</p> {{ end }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
Reference in new issue
Block a user