diff options
author | Dillon <dillonzq@outlook.com> | 2020-03-02 11:50:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 11:50:23 +0300 |
commit | f83b1c14c88b36de419e0eeb3b7e335434bb2032 (patch) | |
tree | 6efa7d9796ed912082187f7ec7df45680b3d3eb7 /layouts | |
parent | aaff1514db6ef154465dc016845442829d620a39 (diff) | |
parent | f8a7fd1df98f3a8c1426044b7d627306b91e6e7a (diff) |
Merge pull request #104 from dillonzq/feature/add_some_shortcodes
feat(shortcodes): replace [align]/[float] with [style] and add [style]
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/shortcodes/align.html | 4 | ||||
-rw-r--r-- | layouts/shortcodes/float.html | 4 | ||||
-rw-r--r-- | layouts/shortcodes/image.html | 16 | ||||
-rw-r--r-- | layouts/shortcodes/style.html | 3 |
4 files changed, 19 insertions, 8 deletions
diff --git a/layouts/shortcodes/align.html b/layouts/shortcodes/align.html deleted file mode 100644 index 8ef2b2c..0000000 --- a/layouts/shortcodes/align.html +++ /dev/null @@ -1,4 +0,0 @@ -{{- /* [left, center, right] */ -}} -<div class={{ .Get 0 | printf "align-%s" }}> - {{- .Inner | .Page.RenderString -}} -</div> diff --git a/layouts/shortcodes/float.html b/layouts/shortcodes/float.html deleted file mode 100644 index 0845ba6..0000000 --- a/layouts/shortcodes/float.html +++ /dev/null @@ -1,4 +0,0 @@ -{{- /* [left, right] */ -}} -<div class={{ .Get 0 | printf "float-%s" }}> - {{- .Inner | .Page.RenderString -}} -</div> diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html new file mode 100644 index 0000000..e2d4f77 --- /dev/null +++ b/layouts/shortcodes/image.html @@ -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> diff --git a/layouts/shortcodes/style.html b/layouts/shortcodes/style.html new file mode 100644 index 0000000..f5848c5 --- /dev/null +++ b/layouts/shortcodes/style.html @@ -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 -}} |