Another experiment for image links.

This commit is contained in:
mtail 2018-05-31 12:16:35 -07:00
parent 1811057b0d
commit 61a4a6a2ec
1 changed files with 12 additions and 10 deletions

View File

@ -32,19 +32,21 @@ parameter.
{{ $alt := or (.Get "alt") (.Get "title") (.Get "caption") }}
{{/* Turn relative values for $link into absolute URLs */}}
{{ $prefix := slicestr $link 0 1 }}
{{ if (eq $prefix "/") }}
{{ .Scratch.Set "link" $link }}
{{ else }}
{{ $prefix := slicestr $link 0 1 }}
{{ if (ne $prefix "/") }}
{{ $prefix := slicestr $link 0 8 }}
{{ if (ne $prefix "https://") }}
{{ $prefix := slicestr $link 0 3 }}
{{ if (eq $prefix "../") }}
{{ $link := slicestr $link 3 }}
{{ .Scratch.Set "link" (printf "/%s%s" .Page.Dir $link) }}
{{ .Scratch.Set "link" (printf "/%s%s" .Page.Dir (slicestr $link 3)) }}
{{ else }}
{{ .Scratch.Set "link" (printf "/%s%s" .Page.Dir $link) }}
{{ end }}
{{ end }}
{{ $link := printf "%s%s" .Site.BaseURL (.Scratch.Get "link") }}
{{ end }}
{{ $link := .Scratch.Get "link" }}
<figure style="width: {{ $width }}">
<div class="wrapper-with-intrinsic-ratio" style="padding-bottom: {{ $ratio }}">