Revert "replace to work with Hugo before 0.48 #40"

This reverts commit 3510227568.

revert changes
This commit is contained in:
Huy Tran 2018-09-23 09:50:55 +10:00
parent 3b0d6601f5
commit 1bd94c5f7a
2 changed files with 11 additions and 11 deletions

View file

@ -1,19 +1,18 @@
{{ if .Site.Params.highlightjs }} {{ if .Site.Params.highlightjs }}
{{ if or (not (isset .Params "highlight")) (.Params.highlight) }} {{ if or (not (isset .Params "highlight")) (.Params.highlight) }}
{{ .Scratch.Set "hl_languages" (union (.Site.Params.highlightjslanguages) (.Params.highlightjslanguages)) }} {{ $hl := newScratch }}
{{ $hl.Set "languages" (union (.Site.Params.highlightjslanguages) (.Params.highlightjslanguages)) }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
{{ with .Scratch.Get "hl_languages" }} {{ with $hl.Get "languages" }}
{{ range . }} {{ range . }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/{{.}}.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/{{.}}.min.js"></script>
{{ end }} {{ end }}
{{ end }} {{ end }}
<script type="text/javascript"> <script type="text/javascript">
{{ with .Scratch.Get "hl_languages" }} hljs.configure({languages: []});
hljs.configure({languages: [{{(delimit . ", ")}}]});
{{ end }}
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();
</script> </script>
{{ .Scratch.Delete "hl_languages" }} {{ $hl.Delete "languages" }}
{{ end }} {{ end }}
{{ end }} {{ end }}

View file

@ -1,7 +1,8 @@
{{ $fig := newScratch }}
{{ if .Get "caption" }} {{ if .Get "caption" }}
{{ $.Scratch.Set "caption" (.Get "caption") }} {{ $fig.Set "caption" (.Get "caption") }}
{{ else if .Get "alt" }} {{ else if .Get "alt" }}
{{ $.Scratch.Set "caption" (.Get "alt") }} {{ $fig.Set "caption" (.Get "alt") }}
{{ end }} {{ end }}
<!-- resolve absolute image path --> <!-- resolve absolute image path -->
{{ $permalink := $.Page.Permalink }} {{ $permalink := $.Page.Permalink }}
@ -28,10 +29,10 @@
/> />
{{ if .Get "link"}}</a>{{ end }} {{ if .Get "link"}}</a>{{ end }}
<!-- caption and attr--> <!-- caption and attr-->
{{ if ($.Scratch.Get "caption") }} {{ if ($fig.Get "caption") }}
<figcaption> <figcaption>
<span class="img--caption"> <span class="img--caption">
Figure {{ $.Page.Scratch.Get "fig" }}. {{ $.Scratch.Get "caption" | markdownify | plainify }} Figure {{ $.Page.Scratch.Get "fig" }}. {{ $fig.Get "caption" | markdownify | plainify }}
{{ if .Get "attr" }} {{ if .Get "attr" }}
[{{- with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" | markdownify }}{{ if .Get "attrlink"}}</a>{{ end -}}] [{{- with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" | markdownify }}{{ if .Get "attrlink"}}</a>{{ end -}}]
{{ end }} {{ end }}
@ -40,4 +41,4 @@
{{ end }} {{ end }}
</figure> </figure>
{{ .Page.Scratch.Add "fig" 1 }} {{ .Page.Scratch.Add "fig" 1 }}
{{ $.Scratch.Delete "caption"}} {{ $fig.Delete "caption"}}