Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 2d382ca

Browse files
authored
Pull template changes from docs site
1 parent d81e594 commit 2d382ca

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

‎layouts/partials/components/author-github-data-card.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
{{ $data := "" }}
66
{{ $url := urls.JoinPath "https://api.github.com/users" $author }}
7-
{{ with resources.GetRemote $url }}
7+
{{ with try (resources.GetRemote $url) }}
88
{{ with .Err }}
99
{{ errorf "%s" . }}
10-
{{ else }}
10+
{{ else with .Value }}
1111
{{ $data = . | transform.Unmarshal }}
12+
{{ else }}
13+
{{ errorf "Unable to get remote resource %q" $url }}
1214
{{ end }}
13-
{{ else }}
14-
{{ errorf "Unable to get remote resource %q" $url }}
1515
{{ end }}
1616

1717
<div class="tc">

‎layouts/partials/components/author-github-data.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
{{ $data := "" }}
66
{{ $url := urls.JoinPath "https://api.github.com/users" $author }}
7-
{{ with resources.GetRemote $url }}
7+
{{ with try (resources.GetRemote $url) }}
88
{{ with .Err }}
99
{{ errorf "%s" . }}
10-
{{ else }}
10+
{{ else with .Value }}
1111
{{ $data = . | transform.Unmarshal }}
12+
{{ else }}
13+
{{ errorf "Unable to get remote resource %q" $url }}
1214
{{ end }}
13-
{{ else }}
14-
{{ errorf "Unable to get remote resource %q" $url }}
1515
{{ end }}
1616

1717
{{ with $data }}

‎layouts/partials/utilities/get-remote-data.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
{{ $url := . }}
1313
{{ $data := dict }}
14-
{{ with resources.GetRemote $url }}
14+
{{ with try (resources.GetRemote $url) }}
1515
{{ with .Err }}
1616
{{ errorf "%s" . }}
17-
{{ else }}
17+
{{ else with .Value }}
1818
{{ $data = .Content | transform.Unmarshal }}
19+
{{ else }}
20+
{{ errorf "Unable to get remote resource %q" $url }}
1921
{{ end }}
20-
{{ else }}
21-
{{ errorf "Unable to get remote resource %q" $url }}
2222
{{ end }}
2323
{{ return $data }}

‎layouts/shortcodes/hl.html‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- /*
2+
Returns syntax-highlighted code from the given text.
3+
4+
This is useful as a terse way to highlight inline code snippets. Calling the
5+
highlight shortcode for inline snippets is verbose.
6+
*/}}
7+
8+
{{- $code := .Inner | strings.TrimSpace }}
9+
{{- $lang := or (.Get 0) "go" }}
10+
{{- $opts := dict "hl_inline" true "noClasses" true }}
11+
{{- transform.Highlight $code $lang $opts }}

‎layouts/shortcodes/img.html‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120

121121
{{- $validFilters := slice
122122
"autoorient" "brightness" "colorbalance" "colorize" "contrast" "dither"
123-
"gamma" "gaussianblur" "grayscale" "hue" "invert" "none" "opacity" "overlay"
124-
"padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text"
123+
"gamma" "gaussianblur" "grayscale" "hue" "invert" "mask" "none" "opacity"
124+
"overlay" "padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text"
125125
"unsharpmask"
126126
}}
127127

@@ -229,6 +229,12 @@
229229
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
230230
{{- template "validate-arg-count" $ctx }}
231231
{{- $f = images.Invert }}
232+
{{- else if eq $filter "mask" }}
233+
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
234+
{{- template "validate-arg-count" $ctx }}
235+
{{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }}
236+
{{- $maskImage := partial "inline/get-resource.html" $ctx }}
237+
{{- $f = images.Mask $maskImage }}
232238
{{- else if eq $filter "opacity" }}
233239
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
234240
{{- template "validate-arg-count" $ctx }}
@@ -322,11 +328,15 @@
322328
{{- end }}
323329

324330
{{- /* Render. */}}
331+
{{- $class := "di va b--black-20" }}
332+
{{- if eq $filter "mask" }}
333+
{{- $class = "di va" }}
334+
{{- end }}
325335
{{- if $example }}
326336
<p>Original</p>
327-
<img class='di ba b--black-20' style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
337+
<img class="{{ $class}}" style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
328338
<p>Processed</p>
329-
<img class='di ba b--black-20' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
339+
<img class="{{ $class }}" style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
330340
{{- else -}}
331341
<img class='di' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
332342
{{- end }}
@@ -354,15 +364,15 @@
354364
{{- $u := urls.Parse .src }}
355365
{{- $msg := "The %q shortcode was unable to resolve %s. See %s" }}
356366
{{- if $u.IsAbs }}
357-
{{- with resources.GetRemote $u.String }}
367+
{{- with try (resources.GetRemote $u.String) }}
358368
{{- with .Err }}
359369
{{- errorf "%s" . }}
360-
{{- else }}
370+
{{- else with .Value }}
361371
{{- /* This is a remote resource. */}}
362372
{{- $r = . }}
373+
{{- else }}
374+
{{- errorf $msg $.name $u.String $.position }}
363375
{{- end }}
364-
{{- else }}
365-
{{- errorf $msg $.name $u.String $.position }}
366376
{{- end }}
367377
{{- else }}
368378
{{- with .page.Resources.Get (strings.TrimPrefix "./" $u.Path) }}

0 commit comments

Comments
 (0)