Overhaul figures
This commit is contained in:
6
layouts/partials/paige/a.html
Normal file
6
layouts/partials/paige/a.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{{ $class := .class }}
|
||||
{{ $content := .content }}
|
||||
{{ $href := .href }}
|
||||
{{ $style := .style }}
|
||||
|
||||
<a {{ with $class }} {{ . }} {{ end }} {{ with $href }} href="{{ . }}" {{ end }} {{ with $style }} {{ . | safeCSS }} {{ end }}>{{ $content }}</a>
|
15
layouts/partials/paige/figure.html
Normal file
15
layouts/partials/paige/figure.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{{ $caption := .caption | markdownify }}
|
||||
{{ $captionclass := .captionclass | default "figure-caption" }}
|
||||
{{ $captionstyle := .captionstyle }}
|
||||
{{ $class := .class | default "align-items-center d-flex flex-column justify-content-center paige-figure" }}
|
||||
{{ $content := .content | markdownify }}
|
||||
{{ $contentclass := .contentclass }}
|
||||
{{ $contentstyle := .contentstyle }}
|
||||
{{ $style := .style | default .Page.Params.paige.figure.style | default .Page.Site.Params.paige.figure.style }}
|
||||
|
||||
<figure {{ with $class }} class="{{ . }}" {{ end }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }}>
|
||||
<div {{ with $contentclass }} class="{{ . }}" {{ end }} {{ with $contentstyle }} style="{{ . | safeCSS }}" {{ end }}>{{ $content }}</div>
|
||||
{{ with $caption }}
|
||||
<figcaption {{ with $captionclass }} class="{{ . }}" {{ end }} {{ with $captionstyle }} style="{{ . | safeCSS }}" {{ end }}>{{ . }}</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
27
layouts/partials/paige/func-resource.html
Normal file
27
layouts/partials/paige/func-resource.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{{ $page := .page }}
|
||||
{{ $url := .url }}
|
||||
|
||||
{{ $resource := "" }}
|
||||
{{ with $page.Resources.GetMatch $url }}
|
||||
{{ $resource = . }}
|
||||
{{ else }}
|
||||
{{ with $page.Resources.Get (relLangURL $url) }}
|
||||
{{ $resource = . }}
|
||||
{{ else }}
|
||||
{{ with resources.GetMatch $url }}
|
||||
{{ $resource = . }}
|
||||
{{ else }}
|
||||
{{ with resources.Get (relLangURL $url) }}
|
||||
{{ $resource = . }}
|
||||
{{ else }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ $resource = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if not $resource }}
|
||||
{{ errorf "invalid resource: %q" $url }}
|
||||
{{ end }}
|
||||
{{ return $resource }}
|
@@ -1,26 +0,0 @@
|
||||
{{ $image := .image }}
|
||||
{{ $caption := .caption }}
|
||||
{{ $method := .method }}
|
||||
{{ $options := .options }}
|
||||
|
||||
{{ $thumbnail := $image }}
|
||||
{{ with $image }}
|
||||
{{ if eq $method "crop" }}
|
||||
{{ $thumbnail = .Crop $options }}
|
||||
{{ else if eq $method "fill" }}
|
||||
{{ $thumbnail = .Fill $options }}
|
||||
{{ else if eq $method "fit" }}
|
||||
{{ $thumbnail = .Fit $options }}
|
||||
{{ else if eq $method "resize" }}
|
||||
{{ $thumbnail = .Resize $options }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<figure class="d-table mb-0">
|
||||
<a href="{{ $image.RelPermalink }}">
|
||||
<img class="{{ if $caption }}figure-img {{ end }}img-fluid" loading="lazy" src="{{ $thumbnail.RelPermalink }}">
|
||||
</a>
|
||||
{{ with $caption }}
|
||||
<figcaption class="figure-caption text-center" style="display: table-caption; caption-side: bottom">{{ . }}</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
55
layouts/partials/paige/image-figure.html
Normal file
55
layouts/partials/paige/image-figure.html
Normal file
@@ -0,0 +1,55 @@
|
||||
{{ $alt := .alt }}
|
||||
{{ $caption := .caption }}
|
||||
{{ $captionclass := .captionclass }}
|
||||
{{ $captionstyle := .captionstyle }}
|
||||
{{ $class := .class }}
|
||||
{{ $contentclass := .contentclass }}
|
||||
{{ $contentstyle := .contentstyle }}
|
||||
{{ $height := .height }}
|
||||
{{ $imageclass := .imageclass | default "img-fluid" }}
|
||||
{{ $imagestyle := .imagestyle }}
|
||||
{{ $link := .link }}
|
||||
{{ $method := .method }}
|
||||
{{ $options := .options }}
|
||||
{{ $page := .page }}
|
||||
{{ $resource := .resource }}
|
||||
{{ $src := .src }}
|
||||
{{ $style := .style }}
|
||||
{{ $title := .title }}
|
||||
{{ $width := .width }}
|
||||
|
||||
{{ if and (not $contentclass) $caption }}
|
||||
{{ $contentclass = "figure-img" }}
|
||||
{{ end }}
|
||||
|
||||
{{ $content := partial "paige/img.html" (dict
|
||||
"alt" $alt
|
||||
"class" $imageclass
|
||||
"height" $height
|
||||
"method" $method
|
||||
"options" $options
|
||||
"page" $page
|
||||
"resource" $resource
|
||||
"src" $src
|
||||
"style" $imagestyle
|
||||
"title" $title
|
||||
"width" $width
|
||||
) }}
|
||||
|
||||
{{ if $link }}
|
||||
{{ $content = partial "paige/a.html" (dict
|
||||
"content" $content
|
||||
"href" $link
|
||||
) }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "paige/figure.html" (dict
|
||||
"caption" $caption
|
||||
"captionclass" $captionclass
|
||||
"captionstyle" $captionstyle
|
||||
"class" $class
|
||||
"content" $content
|
||||
"contentclass" $contentclass
|
||||
"contentstyle" $contentstyle
|
||||
"style" $style
|
||||
) }}
|
38
layouts/partials/paige/img.html
Normal file
38
layouts/partials/paige/img.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{{ $alt := .alt }}
|
||||
{{ $class := .class }}
|
||||
{{ $height := .height }}
|
||||
{{ $loading := .loading | default "lazy" }}
|
||||
{{ $method := .method }}
|
||||
{{ $options := .options }}
|
||||
{{ $page := .page }}
|
||||
{{ $referrerpolicy := .referrerpolicy | default "no-referrer" }}
|
||||
{{ $resource := .resource }}
|
||||
{{ $src := .src }}
|
||||
{{ $style := .style }}
|
||||
{{ $title := .title }}
|
||||
{{ $width := .width }}
|
||||
|
||||
{{ if not $resource }}
|
||||
{{ $resource = partial "paige/func-resource.html" (dict
|
||||
"page" $page
|
||||
"url" $src
|
||||
) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and $method $options }}
|
||||
{{ if eq $method "crop" }}
|
||||
{{ $resource = $resource.Crop $options }}
|
||||
{{ else if eq $method "fill" }}
|
||||
{{ $resource = $resource.Fill $options }}
|
||||
{{ else if eq $method "fit" }}
|
||||
{{ $resource = $resource.Fit $options }}
|
||||
{{ else if eq $method "resize" }}
|
||||
{{ $resource = $resource.Resize $options }}
|
||||
{{ else }}
|
||||
{{ errorf "invalid method: %q" $method }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $src = ($resource | fingerprint).RelPermalink }}
|
||||
|
||||
<img {{ with $alt }} alt="{{ . }}" {{ end }} {{ with $class }} class="{{ . }}" {{ end }} {{ with $height }} height="{{ . }}" {{ end }} loading="{{ $loading }}" referrerpolicy="{{ $referrerpolicy }}" src="{{ $src }}" {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ with $title }} title="{{ . }}" {{ end }} {{ with $width }} width="{{ . }}" {{ end }}>
|
@@ -33,6 +33,10 @@ section[class="paige-metadata"] {
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
.paige-figure > div > div[class="highlight"] > pre, .paige-figure > div > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.paige-header-link {
|
||||
display: none;
|
||||
margin-left: 0.5ch;
|
||||
|
Reference in New Issue
Block a user