Add height, width params to all shortcodes

master
Will Faught 3 years ago
parent 5bb75fb8cb
commit c8e955bd36

@ -24,6 +24,22 @@ Don't believe everything you read on the Internet.
Code:
```go-text-template
{{</* paige/quote caption="Abraham Lincoln" */>}}
Don't believe everything you read on the Internet.
{{</* /paige/quote */>}}
```
Result:
{{< paige/quote caption="Abraham Lincoln" >}}
Don't believe everything you read on the Internet.
{{< /paige/quote >}}
---
Code:
```go-text-template
{{</* paige/quote cite="Abraham Lincoln" */>}}
Don't believe everything you read on the Internet.

@ -1,6 +1,52 @@
{{ $caption := .caption | markdownify }}
{{ $content := .content | markdownify }}
{{ $float := .float }}
{{ $height := .height }}
{{ $maxheight := .maxheight }}
{{ $maxwidth := .maxwidth }}
{{ $width := .width }}
{{ $style := "" }}
{{ if $height }}
{{ with printf "height: %v" $height }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxheight }}
{{ with printf "max-height: %v" $maxheight }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $margins := "" }}
{{ if $float }}
@ -13,9 +59,15 @@
{{ end }}
{{ end }}
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} justify-content-center {{ with $margins }} {{ . }} {{ end }} paige-figure">
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} {{ with $margins }} {{ . }} {{ end }} paige-figure">
{{ with $style }}
<div class="align-items-center d-flex flex-column justify-content-center" style="{{ . | safeCSS }}">
{{ end }}
<div class="{{ if $caption }} mb-2 {{ end }} mw-100">{{ $content }}</div>
{{ with $caption }}
<figcaption class="figure-caption">{{ . }}</figcaption>
{{ end }}
{{ if $style }}
</div>
{{ end }}
</figure>

@ -87,15 +87,15 @@
{{ end }}
</figure>
{{ else if $float }}
{{ $margins := "" }}
{{ $margin := "" }}
{{ if eq $float "start" }}
{{ $margins = "me-4" }}
{{ $margin = "me-4" }}
{{ else if eq $float "end" }}
{{ $margins = "ms-4" }}
{{ $margin = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
<figure class="d-table float-{{ $float }} {{ $margins }} paige-figure text-center" {{ with $style }} style="{{ . }}" {{ end }}>
<figure class="d-table float-{{ $float }} {{ $margin }} paige-figure text-center" {{ with $style }} style="{{ . | safeCSS }}" {{ end }}>
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" style="caption-side: bottom; display: table-caption">{{ . }}</figcaption>

@ -1,5 +1,9 @@
{{ $caption := .Get 0 | default (.Get "caption") }}
{{ $float := .Get "float" }}
{{ $height := .Get "height" }}
{{ $maxheight := .Get "maxheight" }}
{{ $maxwidth := .Get "maxwidth" }}
{{ $width := .Get "width" }}
{{ $content := .Inner }}
@ -7,4 +11,8 @@
"caption" $caption
"content" $content
"float" $float
"height" $height
"maxheight" $maxheight
"maxwidth" $maxwidth
"width" $width
) }}

@ -2,9 +2,55 @@
{{ $caption := .Get "caption" | markdownify }}
{{ $cite := (.Get 0 | default (.Get "cite")) | markdownify }}
{{ $float := .Get "float" }}
{{ $height := .Get "height" }}
{{ $maxheight := .Get "maxheight" }}
{{ $maxwidth := .Get "maxwidth" }}
{{ $width := .Get "width" }}
{{ $content := .Inner | markdownify }}
{{ $style := "" }}
{{ if $height }}
{{ with printf "height: %v" $height }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxheight }}
{{ with printf "max-height: %v" $maxheight }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $margins := "" }}
{{ if $float }}
{{ if eq $float "start" }}
@ -17,13 +63,17 @@
{{ end }}
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} {{ with $margins }} {{ . }} {{ end }} paige-figure">
<div>
<blockquote class="blockquote {{ if $caption }} mb-2 {{ end }} text-{{ $align }}">{{ $content }}</blockquote>
{{ with $style }}
<div class="align-items-center d-flex flex-column justify-content-center" style="{{ . | safeCSS }}">
{{ end }}
<blockquote class="blockquote {{ if $caption }} mb-2 {{ else if not $cite }} mb-0 {{ end }} text-{{ $align }}">{{ $content }}</blockquote>
{{ with $caption }}
<figcaption class="figure-caption text-center">{{ . }}</figcaption>
<figcaption class="figure-caption">{{ . }}</figcaption>
{{ end }}
{{ with $cite }}
<figcaption class="blockquote-footer figure-caption text-{{ $align }}">{{ . }}</figcaption>
<figcaption class="blockquote-footer figure-caption mb-0 text-{{ $align }}">{{ . }}</figcaption>
{{ end }}
{{ if $style }}
</div>
{{ end }}
</figure>

Loading…
Cancel
Save