Add float param to shortcodes

master
Will Faught 3 years ago
parent 92a3166625
commit 03790e5bb0

@ -511,7 +511,7 @@ title: Search
The `paige/figure` shortcode provides a figure with centered content.
```
{{< paige/figure caption="My caption" >}}
{{< paige/figure caption="My caption" float="left" >}}
My content
{{< /paige/figure >}}
```
@ -523,6 +523,8 @@ Parameters:
<dd>Required. String. Markdown. The inner content.</dd>
<dt><code>caption</code></dt>
<dd>Optional. Position 0. String. Markdown. Descriptive text that appears centered below the content.</dd>
<dt><code>float</code></dt>
<dd>Optional. String. Float to one side of its container. Must be <code>start</code> or <code>end</code>.</dd>
</dl>
### Quote
@ -530,7 +532,7 @@ Parameters:
The `paige/quote` shortcode provides a figure with a centered quotation.
```
{{< paige/quote align="center" caption="My caption" cite="My citation" >}}
{{< paige/quote align="center" caption="My caption" cite="My citation" float="left" >}}
My content
{{< /paige/quote >}}
```
@ -546,6 +548,8 @@ Parameters:
<dd>Optional. String. Markdown. Descriptive text that appears centered below the quotation. Must not be used with <code>cite</code>.</dd>
<dt><code>cite</code></dt>
<dd>Optional. Position 0. String. Markdown. Citation text that appears centered below the quotation. Must not be used with <code>caption</code>.</dd>
<dt><code>float</code></dt>
<dd>Optional. String. Float to one side of its container. Must be <code>start</code> or <code>end</code>.</dd>
</dl>
### Code
@ -553,7 +557,7 @@ Parameters:
The `paige/code` shortcode provides a figure with centered code.
```
{{< paige/code caption="My caption" lang="html" options="linenos=true" >}}
{{< paige/code caption="My caption" float="left" lang="html" options="linenos=true" >}}
<!doctype html>
<html lang="en">
<body>
@ -570,6 +574,8 @@ Parameters:
<dd>Required. String. Markdown. The inner content.</dd>
<dt><code>caption</code></dt>
<dd>Optional. String. Markdown. Descriptive text that appears centered below the code.</dd>
<dt><code>float</code></dt>
<dd>Optional. String. Float to one side of its container. Must be <code>start</code> or <code>end</code>.</dd>
<dt><code>lang</code></dt>
<dd>Optional. Position 0. String. Chroma language code. Defaults to <code>plaintext</code>. See <a href="https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages">available codes</a>.</dd>
<dt><code>options</code></dt>
@ -584,6 +590,7 @@ The `paige/image` shortcode provides a figure with a centered image.
{{< paige/image
alt="My alt" >}}
caption="My caption"
float="left"
height="10rem"
link="https://github.com/willfaught/paige"
maxheight="10rem"
@ -602,6 +609,8 @@ Parameters:
<dd>Optional. String. Plain text. Image alt.</dd>
<dt><code>caption</code></dt>
<dd>Optional. String. Markdown. Descriptive text that appears centered below the image.</dd>
<dt><code>float</code></dt>
<dd>Optional. String. Float to one side of its container. Must be <code>start</code> or <code>end</code>.</dd>
<dt><code>height</code></dt>
<dd>Optional. String. Image height.</dd>
<dt><code>link</code></dt>

@ -88,6 +88,26 @@ q = 'q = %s%s%s; print(q %% (chr(39), q, chr(39)))'; print(q % (chr(39), q, chr(
Code:
```go-text-template
{{</* paige/code caption="Python quine" float="end" */>}}
q = 'q = %r; print(q %% q)'; print(q % q)
{{</* /paige/code */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Do the right thing here. String this blind girl along so that dad doesn't have to pay his debt to society. Dead Dove DO NOT EAT. Come on, this is a Bluth family celebration. It's no place for children. If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar.
```
Result:
{{< paige/code caption="Python quine" float="end" >}}
q = 'q = %r; print(q %% q)'; print(q % q)
{{< /paige/code >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Do the right thing here. String this blind girl along so that dad doesn't have to pay his debt to society. Dead Dove DO NOT EAT. Come on, this is a Bluth family celebration. It's no place for children. If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar.
---
Code:
```go-text-template
{{</* paige/code caption="Who you gonna call?" */>}}
---

@ -40,6 +40,26 @@ Don't believe everything you read on the Internet.
Code:
```go-text-template
{{</* paige/figure caption="Abraham Lincoln" float="start" */>}}
Don't believe everything you read on the Internet.
{{</* /paige/figure */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
```
Result:
{{< paige/figure caption="Abraham Lincoln" float="start" >}}
Don't believe everything you read on the Internet.
{{< /paige/figure >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
---
Code:
```go-text-template
{{</* paige/figure caption="Hickory Dickory Dock" */>}}
<pre style="font-family: inherit; font-size: 1rem">

@ -27,3 +27,23 @@ Code:
Result:
{{< paige/image src="stretch.webp" caption="Landscape" width="50%" link="https://github.com/willfaught/paige" >}}
---
Code:
```go-text-template
{{</* paige/image src="stretch.webp" caption="Landscape" width="25%" link="https://github.com/willfaught/paige" float="start" */>}}
{{</* paige/image src="stretch.webp" caption="Landscape" width="25%" link="https://github.com/willfaught/paige" float="end" */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Let's see some bananas and nuts! So Ann, the question is, do you want a man or a boy? I know how I would answer. Never once touched my per diem. I'd go to Craft Service, get some raw veggies, bacon, Cup-A-Soup…baby, I got a stew goin'. You might enjoy this. Oh. Em. Gee. That's amazing. I've always been deeply passionate about nature. Perhaps you remember Neuterfest? I'll never forget your wedding. But I did finally get into Dad's pants. Although I had to have the crotch taken in a little bit. She's a girl, I need to teach her how to be a woman. Within her lies a queen. Let me out that queen. There are dozens of us! Dozens! Oh please. They didn't sneak into this country to be your friends. No one's called him Baby Buster since high school. I mean, it's one banana, Michael. What could it cost, ten dollars? "Circumvent." It means "to go around." Gob: The old "reach around." Mom always taught us to curl up in a ball and remain motionless when confronted. You're Killing Me, Buster.
```
Result:
{{< paige/image src="stretch.webp" caption="Landscape" width="25%" link="https://github.com/willfaught/paige" float="start" >}}
{{< paige/image src="stretch.webp" caption="Landscape" width="25%" link="https://github.com/willfaught/paige" float="end" >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Let's see some bananas and nuts! So Ann, the question is, do you want a man or a boy? I know how I would answer. Never once touched my per diem. I'd go to Craft Service, get some raw veggies, bacon, Cup-A-Soup…baby, I got a stew goin'. You might enjoy this. Oh. Em. Gee. That's amazing. I've always been deeply passionate about nature. Perhaps you remember Neuterfest? I'll never forget your wedding. But I did finally get into Dad's pants. Although I had to have the crotch taken in a little bit. She's a girl, I need to teach her how to be a woman. Within her lies a queen. Let me out that queen. There are dozens of us! Dozens! Oh please. They didn't sneak into this country to be your friends. No one's called him Baby Buster since high school. I mean, it's one banana, Michael. What could it cost, ten dollars? "Circumvent." It means "to go around." Gob: The old "reach around." Mom always taught us to curl up in a ball and remain motionless when confronted. You're Killing Me, Buster.

@ -88,6 +88,26 @@ Use the Force, Harry.
Code:
```go-text-template
{{</* paige/quote cite="Abraham Lincoln" float="end" */>}}
Don't believe everything you read on the Internet.
{{</* /paige/quote */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Do the right thing here. String this blind girl along so that dad doesn't have to pay his debt to society. Dead Dove DO NOT EAT. Come on, this is a Bluth family celebration. It's no place for children. If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. She's not 'that Mexican', Mom. She's my Mexican. And she's Colombian or something. Friday night.
```
Result:
{{< paige/quote cite="Abraham Lincoln" float="end" >}}
Don't believe everything you read on the Internet.
{{< /paige/quote >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar. Do the right thing here. String this blind girl along so that dad doesn't have to pay his debt to society. Dead Dove DO NOT EAT. Come on, this is a Bluth family celebration. It's no place for children. If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. She's not 'that Mexican', Mom. She's my Mexican. And she's Colombian or something. Friday night.
---
Code:
```go-text-template
{{</* paige/quote caption="Hickory Dickory Dock" align="start" */>}}
<div style="white-space: pre">Hickory dickory dock.

@ -1,7 +1,19 @@
{{ $caption := .caption | markdownify }}
{{ $content := .content | markdownify }}
{{ $float := .float }}
<figure class="align-items-center d-flex flex-column justify-content-center paige-figure">
{{ $margins := "" }}
{{ if $float }}
{{ if eq $float "start" }}
{{ $margins = "me-4" }}
{{ else if eq $float "end" }}
{{ $margins = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
{{ end }}
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} justify-content-center {{ with $margins }} {{ . }} {{ end }} paige-figure">
<div class="{{ if $caption }} mb-2 {{ end }} mw-100">{{ $content }}</div>
{{ with $caption }}
<figcaption class="figure-caption">{{ . }}</figcaption>

@ -1,5 +1,6 @@
{{ $alt := .alt }}
{{ $caption := .caption }}
{{ $float := .float }}
{{ $height := .height }}
{{ $link := .link }}
{{ $maxheight := .maxheight }}
@ -21,16 +22,12 @@
{{ $content := partial "paige/img.html" (dict
"alt" $alt
"class" $class
"height" $height
"maxheight" $maxheight
"maxwidth" $maxwidth
"method" $method
"options" $options
"page" $page
"resource" $resource
"src" $src
"title" $title
"width" $width
) }}
{{ if $link }}
@ -40,9 +37,83 @@
) }}
{{ end }}
<figure class="{{ if $table }} d-table mb-0 {{ end }} paige-figure text-center">
{{ $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 }}
{{ if $table }}
<figure class="d-table mb-0 paige-figure text-center">
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" style="caption-side: bottom; display: table-caption">{{ . }}</figcaption>
{{ end }}
</figure>
{{ else if $float }}
{{ $margins := "" }}
{{ if eq $float "start" }}
{{ $margins = "me-4" }}
{{ else if eq $float "end" }}
{{ $margins = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
<figure class="d-table float-{{ $float }} {{ $margins }} paige-figure text-center" {{ with $style }} style="{{ . }}" {{ end }}>
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" style="caption-side: bottom; display: table-caption">{{ . }}</figcaption>
{{ end }}
</figure>
{{ else }}
<figure class="paige-figure text-center">
{{ with $style }}
<div class="align-items-center d-flex flex-column">
<div style="{{ . }}">
{{ end }}
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" {{ if $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
<figcaption class="figure-caption">{{ . }}</figcaption>
{{ end }}
{{ if $style }}
</div>
</div>
{{ end }}
</figure>
{{ end }}

@ -1,4 +1,5 @@
{{ $caption := .Get "caption" }}
{{ $float := .Get "float" }}
{{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }}
{{ $options := .Get "options" }}
@ -7,4 +8,5 @@
{{ partial "paige/figure.html" (dict
"caption" $caption
"content" $content
"float" $float
) }}

@ -1,8 +1,10 @@
{{ $caption := .Get 0 | default (.Get "caption") }}
{{ $float := .Get "float" }}
{{ $content := .Inner }}
{{ partial "paige/figure.html" (dict
"caption" $caption
"content" $content
"float" $float
) }}

@ -1,5 +1,6 @@
{{ $alt := .Get "alt" }}
{{ $caption := .Get "caption" }}
{{ $float := .Get "float" }}
{{ $height := .Get "height" }}
{{ $link := .Get "link" }}
{{ $maxheight := .Get "maxheight" }}
@ -13,6 +14,7 @@
{{ partial "paige/image-figure.html" (dict
"alt" $alt
"caption" $caption
"float" $float
"height" $height
"link" $link
"maxheight" $maxheight

@ -1,12 +1,24 @@
{{ $align := .Get "align" | default "center" }}
{{ $caption := .Get "caption" }}
{{ $cite := .Get 0 | default (.Get "cite") }}
{{ $float := .Get "float" }}
{{ $caption = $caption | markdownify }}
{{ $cite = $cite | markdownify }}
{{ $content := .Inner | markdownify }}
<figure class="d-flex align-items-center flex-column paige-figure">
{{ $margins := "" }}
{{ if $float }}
{{ if eq $float "start" }}
{{ $margins = "me-4" }}
{{ else if eq $float "end" }}
{{ $margins = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
{{ end }}
<figure class="d-flex align-items-center 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 $caption }}

Loading…
Cancel
Save