You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
HTML
49 lines
1.3 KiB
HTML
{{ $params := . }}
|
|
|
|
{{ $page := $params.page }}
|
|
{{ $url := $params.url }}
|
|
|
|
{{ $result := "" }}
|
|
|
|
{{ if (urls.Parse $url).Scheme }}
|
|
{{ with try (resources.GetRemote $url) }}
|
|
{{ with .Err }}
|
|
{{ errorf "layouts/partials/paige/func-resource.html: cannot get remote resource %q: %v" $url . }}
|
|
{{ else with .Value }}
|
|
{{ $result = . }}
|
|
{{ else }}
|
|
{{ errorf "layouts/partials/paige/func-resource.html: cannot find remote resource %q" $url }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if and (not $result) $page }}
|
|
{{ with $page.Resources.GetMatch $url }}
|
|
{{ $result = . }}
|
|
{{ else with $page.Resources.Get $url }}
|
|
{{ $result = . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if not $result }}
|
|
{{ with resources.GetMatch $url }}
|
|
{{ $result = . }}
|
|
{{ else with resources.Get $url }}
|
|
{{ $result = . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if $result }}
|
|
{{ with urls.Parse $url }}
|
|
{{ if .Scheme }}
|
|
{{ $path := print ($result.MediaType.SubType) "/paige" $result.RelPermalink }}
|
|
|
|
{{ $result = resources.Copy $path $result }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ errorf "layouts/partials/paige/func-resource.html: cannot find resource %q" $url }}
|
|
{{ end }}
|
|
|
|
{{ return $result }}
|