shortcodes: add support for picture comparisons

This commit is contained in:
liushuyu 2021-07-09 16:49:55 -06:00
parent 9f449cfedd
commit ea75958a39
No known key found for this signature in database
GPG Key ID: 23D1CE4534419437
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,2 @@
<script src="https://cdn.jsdelivr.net/npm/juxtaposejs@1.1.6/build/js/juxtapose.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/juxtaposejs@1.1.6/build/css/juxtapose.css">

View File

@ -0,0 +1,22 @@
{{ $title := .Get 0 }}
<div class="columns is-bottom-marginless">
<div class="column is-bottom-paddingless juxtapose">
{{ range $param := last 2 .Params }}
<!-- image -->
{{ $items := split $param "|" }}
{{ $src := (index $items 0) }}
{{ $subtitle := (index $items 1) }}
{{ $split_src := split $src "." }}
{{ $extension := index $split_src (sub (len $split_src) 1) }}
{{- if eq $extension "png" -}}
<img src="{{ $src }}.jpg" alt="{{ $title }}">
{{- else -}}
<img src="{{ $src }}" alt="{{ $title }}">
{{- end -}}
{{ end }}
</div>
</div>
{{ if $title }}
<p class="has-text-centered is-italic has-text-grey-light">{{ $title }}</p>
{{ end }}