feat(shortcodes): replace [align]/[float] with [style] and add [style]

This commit is contained in:
Dillon
2020-03-02 16:47:28 +08:00
parent aaff1514db
commit f8a7fd1df9
8 changed files with 24 additions and 33 deletions

View File

@@ -1,4 +0,0 @@
{{- /* [left, center, right] */ -}}
<div class={{ .Get 0 | printf "align-%s" }}>
{{- .Inner | .Page.RenderString -}}
</div>

View File

@@ -1,4 +0,0 @@
{{- /* [left, right] */ -}}
<div class={{ .Get 0 | printf "float-%s" }}>
{{- .Inner | .Page.RenderString -}}
</div>

View File

@@ -0,0 +1,16 @@
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- $options := .Get "src" | dict "src" -}}
{{- $options = .Get "src_s" | dict "src_s" | merge $options -}}
{{- $options = .Get "src_l" | dict "src_l" | merge $options -}}
{{- $options = .Get "title" | dict "title" | merge $options -}}
{{- $options = .Get "description" | dict "description" | merge $options -}}
{{- $lightgallery := ne .Page.Site.Params.page.lightgallery false | and (ne .Page.Params.lightgallery false) -}}
{{- $options = $lightgallery | dict "lightgallery" | merge $options -}}
{{- $options = .Page.Scratch.Get "scratch" | dict "scratch" | merge $options -}}
{{- partial "plugin/image.html" $options -}}
{{- with (.Get "title" | default .Get "description") -}}
<figcaption class="image-caption">
{{- . | safeHTML -}}
</figcaption>
{{- end -}}
</figure>

View File

@@ -0,0 +1,3 @@
{{- $content := .Inner | .Page.RenderString -}}
{{- $tag := .Get 1 | default "div" -}}
{{- printf `<%s style="%s">%s</%s>` $tag ($.Get 0) $content $tag | safeHTML -}}