xianmin / hugo-theme-jane

A readable & concise theme for Hugo, color schemes to choose, easy to personalize. Working well since 2018.
https://xianmin.github.io/hugo-theme-jane/
MIT License
931 stars 288 forks source link

Hugo figure shortcode backwards compatibility #223

Closed paskal closed 5 years ago

paskal commented 5 years ago

Hugo's figure.html is different from this theme figure.html: it supports caption-effect, caption-position, figurecount, size, thumb parameters, but doesn't support height, rel and target. To be truly backwards compatible we should add missing parameters support to this theme figure.html template.

paskal commented 5 years ago

Fixing rel and target is trivial:

--- ./themes/hugo-theme-jane/layouts/shortcodes/figure.html+0000
+++ ./fix/layouts/shortcodes/figure.html
@@ -15,7 +15,7 @@
     <div class="img"{{ if .Parent }} style="background-image: url('{{ print $thumb }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
       <img itemprop="thumbnail" src="{{ $thumb }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
     </div>
-    {{ with .Get "link" | default (.Get "src") }}<a href="{{.}}" itemprop="contentUrl"></a>{{ end }}
+    {{ with .Get "link" | default (.Get "src") }}<a href="{{.}}"{{ with $.Get "target" }} target="{{.}}"{{ end }}{{ with $.Get "rel" }} rel="{{.}}"{{ end }} itemprop="contentUrl"></a>{{ end }}
     {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
       <figcaption>
         {{- with .Get "title" }}<h4>{{.}}</h4>{{ end }}

However I'm not familiar enough with css to know how to fix height.

paskal commented 5 years ago

We fixed everything expect height, which might be not needed with auto-width option. Please reopen if needed, my problem is solved and I'm resolving this issue.