Simplify
This commit is contained in:
@@ -20,21 +20,17 @@
|
|||||||
{{ if and (not $result) $page }}
|
{{ if and (not $result) $page }}
|
||||||
{{ with $page.Resources.GetMatch $url }}
|
{{ with $page.Resources.GetMatch $url }}
|
||||||
{{ $result = . }}
|
{{ $result = . }}
|
||||||
{{ else }}
|
{{ else with $page.Resources.Get $url }}
|
||||||
{{ with $page.Resources.Get $url }}
|
|
||||||
{{ $result = . }}
|
{{ $result = . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if not $result }}
|
{{ if not $result }}
|
||||||
{{ with resources.GetMatch $url }}
|
{{ with resources.GetMatch $url }}
|
||||||
{{ $result = . }}
|
{{ $result = . }}
|
||||||
{{ else }}
|
{{ else with resources.Get $url }}
|
||||||
{{ with resources.Get $url }}
|
|
||||||
{{ $result = . }}
|
{{ $result = . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ return $result }}
|
{{ return $result }}
|
||||||
|
|||||||
@@ -86,15 +86,13 @@
|
|||||||
{{ else }}
|
{{ else }}
|
||||||
{{ with findRE `q\d+` . 1 }}
|
{{ with findRE `q\d+` . 1 }}
|
||||||
{{ $quality = index . 0 }}
|
{{ $quality = index . 0 }}
|
||||||
{{ else }}
|
{{ else with findRE `\d+x\d+|\d+x|x\d+` . 1 }}
|
||||||
{{ with findRE `\d+x\d+|\d+x|x\d+` . 1 }}
|
|
||||||
{{ $size = index . 0 }}
|
{{ $size = index . 0 }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $options = $options | append . }}
|
{{ $options = $options | append . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ $options = delimit $options " " }}
|
{{ $options = delimit $options " " }}
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $smallerResource = $smallerResource | fingerprint }}
|
{{ $smallerResource = fingerprint $smallerResource }}
|
||||||
{{ $intrinsicHeight = $smallerResource.Height }}
|
{{ $intrinsicHeight = $smallerResource.Height }}
|
||||||
{{ $intrinsicWidth = $smallerResource.Width }}
|
{{ $intrinsicWidth = $smallerResource.Width }}
|
||||||
{{ $src = $smallerResource.Permalink }}
|
{{ $src = $smallerResource.Permalink }}
|
||||||
@@ -182,7 +180,7 @@
|
|||||||
{{ $resized = $smallerResource.Resize (print $imageWidth "x q100 " $options) }}
|
{{ $resized = $smallerResource.Resize (print $imageWidth "x q100 " $options) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $resized = $resized | fingerprint }}
|
{{ $resized = fingerprint $resized }}
|
||||||
{{ $srcset = $srcset | append (printf "%s %gx" $resized.RelPermalink .) }}
|
{{ $srcset = $srcset | append (printf "%s %gx" $resized.RelPermalink .) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
@@ -210,7 +208,7 @@
|
|||||||
{{ $resized = $smallerResource.Resize (print $imageWidth "x q100 " $options) }}
|
{{ $resized = $smallerResource.Resize (print $imageWidth "x q100 " $options) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $resized = $resized | fingerprint }}
|
{{ $resized = fingerprint $resized }}
|
||||||
{{ $maxWidth = math.Max $maxWidth $imageWidth }}
|
{{ $maxWidth = math.Max $maxWidth $imageWidth }}
|
||||||
{{ $sizes = $sizes | append (printf "(max-width: %dpx) %dpx" $viewWidth $imageWidth) }}
|
{{ $sizes = $sizes | append (printf "(max-width: %dpx) %dpx" $viewWidth $imageWidth) }}
|
||||||
{{ $srcset = $srcset | append (printf "%s %dw" $resized.RelPermalink $imageWidth) }}
|
{{ $srcset = $srcset | append (printf "%s %dw" $resized.RelPermalink $imageWidth) }}
|
||||||
@@ -282,7 +280,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $resource = $resource | fingerprint }}
|
{{ $resource = fingerprint $resource }}
|
||||||
{{ $content = partial "paige/tag-a.html" (dict "content" $content "href" $resource.RelPermalink "page" $page) }}
|
{{ $content = partial "paige/tag-a.html" (dict "content" $content "href" $resource.RelPermalink "page" $page) }}
|
||||||
{{ else if $link }}
|
{{ else if $link }}
|
||||||
{{ $content = partial "paige/tag-a.html" (dict "content" $content "href" $link "page" $page) }}
|
{{ $content = partial "paige/tag-a.html" (dict "content" $content "href" $link "page" $page) }}
|
||||||
|
|||||||
@@ -30,14 +30,12 @@
|
|||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $resources = resources.Match . }}
|
{{ $resources = resources.Match . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else with .Page.Resources.ByType "image" }}
|
||||||
{{ with .Page.Resources.ByType "image" }}
|
|
||||||
{{ $resources = . }}
|
{{ $resources = . }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $resources = resources.ByType "image" }}
|
{{ $resources = resources.ByType "image" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{/* The markup below cannot be indented due to nested shortcodes within Markdown. */}}
|
{{/* The markup below cannot be indented due to nested shortcodes within Markdown. */}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user