Separate gallery and image shortcodes
This commit is contained in:
@@ -213,14 +213,14 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="1 image" */>}}
|
{{</* paige/gallery caption="1 image" */>}}
|
||||||
{{</* paige/gallery image="*-1*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-1*.jpg" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="1 image" >}}
|
{{< paige/gallery caption="1 image" >}}
|
||||||
{{< paige/gallery image="*-1*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-1*.jpg" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -229,16 +229,16 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="2 images" */>}}
|
{{</* paige/gallery caption="2 images" */>}}
|
||||||
{{</* paige/gallery image="*-2*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-2*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-3*.jpg" caption="Image 2" /*/>}}
|
{{</* paige/image src="*-3*.jpg" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="2 images" >}}
|
{{< paige/gallery caption="2 images" >}}
|
||||||
{{< paige/gallery image="*-2*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-2*.jpg" >}}
|
||||||
{{< paige/gallery image="*-3*.jpg" caption="Image 2" />}}
|
{{< paige/image src="*-3*.jpg" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -247,18 +247,18 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="3 images" */>}}
|
{{</* paige/gallery caption="3 images" */>}}
|
||||||
{{</* paige/gallery image="*-4*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-4*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-5*.jpg" caption="Image 2" /*/>}}
|
{{</* paige/image src="*-5*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-6*.jpg" caption="Image 3" /*/>}}
|
{{</* paige/image src="*-6*.jpg" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="3 images" >}}
|
{{< paige/gallery caption="3 images" >}}
|
||||||
{{< paige/gallery image="*-4*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-4*.jpg" >}}
|
||||||
{{< paige/gallery image="*-5*.jpg" caption="Image 2" />}}
|
{{< paige/image src="*-5*.jpg" >}}
|
||||||
{{< paige/gallery image="*-6*.jpg" caption="Image 3" />}}
|
{{< paige/image src="*-6*.jpg" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -267,20 +267,20 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="4 images" */>}}
|
{{</* paige/gallery caption="4 images" */>}}
|
||||||
{{</* paige/gallery image="*-7*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-7*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-8*.jpg" caption="Image 2" /*/>}}
|
{{</* paige/image src="*-8*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-9*.jpg" caption="Image 3" /*/>}}
|
{{</* paige/image src="*-9*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-10.jpg*" caption="Image 4" /*/>}}
|
{{</* paige/image src="*-10.jpg*" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="4 images" >}}
|
{{< paige/gallery caption="4 images" >}}
|
||||||
{{< paige/gallery image="*-7*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-7*.jpg" >}}
|
||||||
{{< paige/gallery image="*-8*.jpg" caption="Image 2" />}}
|
{{< paige/image src="*-8*.jpg" >}}
|
||||||
{{< paige/gallery image="*-9*.jpg" caption="Image 3" />}}
|
{{< paige/image src="*-9*.jpg" >}}
|
||||||
{{< paige/gallery image="*-10.jpg*" caption="Image 4" />}}
|
{{< paige/image src="*-10.jpg*" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -289,22 +289,22 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="5 images" */>}}
|
{{</* paige/gallery caption="5 images" */>}}
|
||||||
{{</* paige/gallery image="*-11*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-11*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-12*.jpg" caption="Image 2" /*/>}}
|
{{</* paige/image src="*-12*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-13*.jpg" caption="Image 3" /*/>}}
|
{{</* paige/image src="*-13*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-14*.jpg" caption="Image 4" /*/>}}
|
{{</* paige/image src="*-14*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-15*.jpg" caption="Image 5" /*/>}}
|
{{</* paige/image src="*-15*.jpg" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="5 images" >}}
|
{{< paige/gallery caption="5 images" >}}
|
||||||
{{< paige/gallery image="*-11*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-11*.jpg" >}}
|
||||||
{{< paige/gallery image="*-12*.jpg" caption="Image 2" />}}
|
{{< paige/image src="*-12*.jpg" >}}
|
||||||
{{< paige/gallery image="*-13*.jpg" caption="Image 3" />}}
|
{{< paige/image src="*-13*.jpg" >}}
|
||||||
{{< paige/gallery image="*-14*.jpg" caption="Image 4" />}}
|
{{< paige/image src="*-14*.jpg" >}}
|
||||||
{{< paige/gallery image="*-15*.jpg" caption="Image 5" />}}
|
{{< paige/image src="*-15*.jpg" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -313,24 +313,24 @@ Code:
|
|||||||
|
|
||||||
```go-text-template
|
```go-text-template
|
||||||
{{</* paige/gallery caption="6 images" */>}}
|
{{</* paige/gallery caption="6 images" */>}}
|
||||||
{{</* paige/gallery image="*-16*.jpg" caption="Image 1" /*/>}}
|
{{</* paige/image src="*-16*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-17*.jpg" caption="Image 2" /*/>}}
|
{{</* paige/image src="*-17*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-18*.jpg" caption="Image 3" /*/>}}
|
{{</* paige/image src="*-18*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-19*.jpg" caption="Image 4" /*/>}}
|
{{</* paige/image src="*-19*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-20*.jpg" caption="Image 5" /*/>}}
|
{{</* paige/image src="*-20*.jpg" /*/>}}
|
||||||
{{</* paige/gallery image="*-21*.jpg" caption="Image 6" /*/>}}
|
{{</* paige/image src="*-21*.jpg" /*/>}}
|
||||||
{{</* /paige/gallery */>}}
|
{{</* /paige/gallery */>}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
{{< paige/gallery caption="6 images" >}}
|
{{< paige/gallery caption="6 images" >}}
|
||||||
{{< paige/gallery image="*-16*.jpg" caption="Image 1" />}}
|
{{< paige/image src="*-16*.jpg" >}}
|
||||||
{{< paige/gallery image="*-17*.jpg" caption="Image 2" />}}
|
{{< paige/image src="*-17*.jpg" >}}
|
||||||
{{< paige/gallery image="*-18*.jpg" caption="Image 3" />}}
|
{{< paige/image src="*-18*.jpg" >}}
|
||||||
{{< paige/gallery image="*-19*.jpg" caption="Image 4" />}}
|
{{< paige/image src="*-19*.jpg" >}}
|
||||||
{{< paige/gallery image="*-20*.jpg" caption="Image 5" />}}
|
{{< paige/image src="*-20*.jpg" >}}
|
||||||
{{< paige/gallery image="*-21*.jpg" caption="Image 6" />}}
|
{{< paige/image src="*-21*.jpg" >}}
|
||||||
{{< /paige/gallery >}}
|
{{< /paige/gallery >}}
|
||||||
|
|
||||||
<div class="text-center">Photos by <a href="https://unsplash.com/@photos_by_lanty">Lanty</a>.</div>
|
<div class="text-center">Photos by <a href="https://unsplash.com/@photos_by_lanty">Lanty</a>.</div>
|
||||||
|
@@ -47,6 +47,10 @@ body, html {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paige-gallery .paige-image {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.paige-figure .paige-image {
|
.paige-figure .paige-image {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
{{ $align := .Get "align" | default "center" }}
|
{{ $align := .Get "align" | default "center" }}
|
||||||
{{ $caption := .Get "caption" }}
|
{{ $caption := .Get "caption" }}
|
||||||
{{ $height := .Get "height" }}
|
{{ $height := .Get "height" }}
|
||||||
{{ $image := .Get "image" }}
|
|
||||||
{{ $images := .Get 0 | default (.Get "images") }}
|
{{ $images := .Get 0 | default (.Get "images") }}
|
||||||
{{ $justify := .Get "justify" | default "center" }}
|
{{ $justify := .Get "justify" | default "center" }}
|
||||||
{{ $maxwidth := .Get "maxwidth" }}
|
{{ $maxwidth := .Get "maxwidth" }}
|
||||||
@@ -9,138 +8,91 @@
|
|||||||
{{ $number := .Get "number" }}
|
{{ $number := .Get "number" }}
|
||||||
{{ $numbered := .Get "numbered" }}
|
{{ $numbered := .Get "numbered" }}
|
||||||
{{ $options := .Get "options" | default "550x webp picture Lanczos" }}
|
{{ $options := .Get "options" | default "550x webp picture Lanczos" }}
|
||||||
{{ $raw := .Get "raw" }}
|
|
||||||
{{ $type := .Get "type" | default "rows" }}
|
{{ $type := .Get "type" | default "rows" }}
|
||||||
{{ $width := .Get "width" }}
|
{{ $width := .Get "width" }}
|
||||||
|
|
||||||
{{ if $image }}
|
{{ $inner := chomp .Inner }}
|
||||||
{{ $link := $image }}
|
{{ $resources := slice }}
|
||||||
{{ $resource := "" }}
|
{{ $showcaption := $caption }}
|
||||||
|
|
||||||
{{ if not $raw }}
|
{{ with $images }}
|
||||||
{{ $resource = partial "paige/resource.html" (dict
|
{{ with $.Page.Resources.Match . }}
|
||||||
"page" .Page
|
{{ $resources = . }}
|
||||||
"url" $image
|
|
||||||
) }}
|
|
||||||
{{ $link = $resource.RelPermalink }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if $caption }}
|
|
||||||
{{ partial "paige/image-figure.html" (dict
|
|
||||||
"caption" $caption
|
|
||||||
"compact" true
|
|
||||||
"gap" 2
|
|
||||||
"height" $height
|
|
||||||
"link" $link
|
|
||||||
"maxwidth" $maxwidth
|
|
||||||
"method" $method
|
|
||||||
"options" $options
|
|
||||||
"page" .Page
|
|
||||||
"raw" $raw
|
|
||||||
"resource" $resource
|
|
||||||
"src" $image
|
|
||||||
"table" true
|
|
||||||
"width" $width
|
|
||||||
) }}
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ partial "paige/a.html" (dict
|
{{ $resources = resources.Match . }}
|
||||||
"content" (partial "paige/img.html" (dict
|
|
||||||
"class" "img-fluid"
|
|
||||||
"height" $height
|
|
||||||
"maxwidth" $maxwidth
|
|
||||||
"method" $method
|
|
||||||
"options" $options
|
|
||||||
"resource" $resource
|
|
||||||
"src" $image
|
|
||||||
"width" $width
|
|
||||||
))
|
|
||||||
"href" $link
|
|
||||||
) }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $inner := chomp .Inner }}
|
{{ with .Page.Resources.ByType "image" }}
|
||||||
{{ $resources := slice }}
|
{{ $resources = . }}
|
||||||
{{ $showcaption := $caption }}
|
|
||||||
|
|
||||||
{{ with $images }}
|
|
||||||
{{ with $.Page.Resources.Match . }}
|
|
||||||
{{ $resources = . }}
|
|
||||||
{{ else }}
|
|
||||||
{{ $resources = resources.Match . }}
|
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ with .Page.Resources.ByType "image" }}
|
{{ $resources = resources.ByType "image" }}
|
||||||
{{ $resources = . }}
|
|
||||||
{{ else }}
|
|
||||||
{{ $resources = resources.ByType "image" }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if $caption }}
|
{{ if $caption }}
|
||||||
{{ if $number }}
|
{{ if $number }}
|
||||||
{{ $caption = printf "%v %v: %v" (i18n "paige_figure") $number $caption }}
|
{{ $caption = printf "%v %v: %v" (i18n "paige_figure") $number $caption }}
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
|
||||||
{{ if $number }}
|
|
||||||
{{ $caption = printf "%v %v" (i18n "paige_figure") $number }}
|
|
||||||
{{ $showcaption = true }}
|
|
||||||
{{ else if $numbered }}
|
|
||||||
{{ $showcaption = true }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
{{ if $number }}
|
||||||
|
{{ $caption = printf "%v %v" (i18n "paige_figure") $number }}
|
||||||
|
{{ $showcaption = true }}
|
||||||
|
{{ else if $numbered }}
|
||||||
|
{{ $showcaption = true }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<figure>
|
<figure class="paige-gallery">
|
||||||
{{ if eq $type "grid" }}
|
{{ if eq $type "grid" }}
|
||||||
<div class="container-fluid px-0">
|
<div class="container-fluid px-0">
|
||||||
<div class="align-items-{{ $align }} gx-3 gy-3 justify-content-{{ $justify }} row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5 row-cols-xxl-6">
|
<div class="align-items-{{ $align }} gx-3 gy-3 justify-content-{{ $justify }} row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5 row-cols-xxl-6">
|
||||||
{{ with $inner }}
|
|
||||||
{{ . }}
|
|
||||||
{{ else }}
|
|
||||||
{{ range $resources }}
|
|
||||||
<div class="col">
|
|
||||||
{{ partial "paige/a.html" (dict
|
|
||||||
"content" (partial "paige/img.html" (dict
|
|
||||||
"class" "img-fluid"
|
|
||||||
"height" $height
|
|
||||||
"maxwidth" $maxwidth
|
|
||||||
"method" $method
|
|
||||||
"options" $options
|
|
||||||
"resource" .
|
|
||||||
"width" $width
|
|
||||||
))
|
|
||||||
"href" .RelPermalink
|
|
||||||
) }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ else if eq $type "rows" }}
|
|
||||||
<div class="align-items-{{ $align }} column-gap-3 d-flex flex-wrap justify-content-{{ $justify }} row-gap-3">
|
|
||||||
{{ with $inner }}
|
{{ with $inner }}
|
||||||
{{ . }}
|
{{ . }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ range $resources }}
|
{{ range $resources }}
|
||||||
{{ partial "paige/a.html" (dict
|
<div class="col">
|
||||||
"content" (partial "paige/img.html" (dict
|
{{ partial "paige/a.html" (dict
|
||||||
"class" "img-fluid"
|
"content" (partial "paige/img.html" (dict
|
||||||
"height" $height
|
"class" "img-fluid"
|
||||||
"maxwidth" $maxwidth
|
"height" $height
|
||||||
"method" $method
|
"maxwidth" $maxwidth
|
||||||
"options" $options
|
"method" $method
|
||||||
"resource" .
|
"options" $options
|
||||||
"width" $width
|
"resource" .
|
||||||
))
|
"width" $width
|
||||||
"href" .RelPermalink
|
))
|
||||||
) }}
|
"href" .RelPermalink
|
||||||
|
) }}
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ else }}
|
</div>
|
||||||
{{ errorf "invalid type: %q" $type }}
|
{{ else if eq $type "rows" }}
|
||||||
{{ end }}
|
<div class="align-items-{{ $align }} column-gap-3 d-flex flex-wrap justify-content-{{ $justify }} row-gap-3">
|
||||||
{{ if $showcaption }}
|
{{ with $inner }}
|
||||||
<figcaption class="figure-caption mt-2 text-center">{{ $caption }}</figcaption>
|
{{ . }}
|
||||||
{{ end }}
|
{{ else }}
|
||||||
</figure>
|
{{ range $resources }}
|
||||||
{{ end }}
|
{{ partial "paige/a.html" (dict
|
||||||
|
"content" (partial "paige/img.html" (dict
|
||||||
|
"class" "img-fluid"
|
||||||
|
"height" $height
|
||||||
|
"maxwidth" $maxwidth
|
||||||
|
"method" $method
|
||||||
|
"options" $options
|
||||||
|
"resource" .
|
||||||
|
"width" $width
|
||||||
|
))
|
||||||
|
"href" .RelPermalink
|
||||||
|
) }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ else }}
|
||||||
|
{{ errorf "invalid type: %q" $type }}
|
||||||
|
{{ end }}
|
||||||
|
{{ if $showcaption }}
|
||||||
|
<figcaption class="figure-caption mt-2 text-center">{{ $caption }}</figcaption>
|
||||||
|
{{ end }}
|
||||||
|
</figure>
|
||||||
|
Reference in New Issue
Block a user