Skip to content

Commit

Permalink
add 'align' parameter to figure shortcode
Browse files Browse the repository at this point in the history
Parameter values:
  - unset or 'default': align according to language direction
  - 'left': align image and captions to left of page
  - 'right': align image and captions to right of page
  - 'center': align image and captions to center of page
  • Loading branch information
kdkasad committed Feb 19, 2021
1 parent 16ae26f commit 29f7fe0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions assets/css/post-single.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,27 @@
margin: auto
}

.post-content figure.align-center {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}

.post-content figure.align-left {
display: flex;
flex-direction: column;
align-items: flex-start;
text-align: left;
}

.post-content figure.align-right {
display: flex;
flex-direction: column;
align-items: flex-end;
text-align: right;
}

.post-content figure > figcaption {
color: var(--primary);
font-size: 16px;
Expand Down
5 changes: 4 additions & 1 deletion layouts/shortcodes/figure.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
<figure{{ if or (.Get "class") (.Get "align") }} class="
{{- with .Get "align" }}align-{{ . }} {{ end }}
{{- with .Get "class" }}{{ . }}{{ end }}"
{{- end -}}>
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }}
Expand Down

0 comments on commit 29f7fe0

Please sign in to comment.