mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
🐛 Fix: get remote image error in link shortcode (#391)
This commit is contained in:
@@ -7,15 +7,16 @@
|
||||
|
||||
{{- if $pass -}}
|
||||
{{- with $remoteResource := resources.GetRemote .Path -}}
|
||||
{{ printf "Remote image: %v" $remoteResource.ResourceType -}}
|
||||
{{- with .Err -}}
|
||||
{{- warnf "%s" . -}}
|
||||
{{ else }}
|
||||
{{- erroridf "error-get-remote-image" "%s" . -}}
|
||||
{{- else -}}
|
||||
{{- if eq $remoteResource.ResourceType "image" -}}
|
||||
{{- /* placed remote image in public/images/remote/ */ -}}
|
||||
{{- $resource = $remoteResource | resources.Copy (add "/images/remote/" $remoteResource.Name) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- erroridf "error-get-remote-image" "Unable to get remote image %q" .Path -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $resource -}}
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
{{- $warns := slice -}}
|
||||
{{- $errors := slice -}}
|
||||
|
||||
{{- with .Site.Params.home.profile.gravatarSite -}}
|
||||
{{- $warns = $warns | append "The parameter `home.profile.gravatarSite` is deprecated since v0.2.14, use `gravatar.host` instead." -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.ibruce.siteTime -}}
|
||||
{{- $warns = $warns | append "The parameter `ibruce.siteTime` is deprecated since v0.2.14, use `footer.siteTime` instead." -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.autoBookmark -}}
|
||||
{{- $warns = $warns | append "The parameter `autoBookmark` is deprecated since v0.2.17, use `page.autoBookmark` instead." -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.footer.siteTime -}}
|
||||
{{- if not (reflect.IsMap .) -}}
|
||||
{{- $warns = $warns | append "The parameter `footer.siteTime` has changed to a Map since v0.2.17. Please correct the format!" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with .Site.Params.gitRepo | or .Site.Params.page.edit -}}
|
||||
{{- $warns = $warns | append "The parameter `params.gitRepo` and `params.page.edit` is deprecated since v0.3.0, use `params.gitInfo` instead." -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -42,10 +42,12 @@
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $cardIcon := .CardIcon -}}
|
||||
{{- if $url.Host | and (eq $cardIcon "") -}}
|
||||
{{- if $url.Host | and (eq .CardIcon true) -}}
|
||||
{{- $cardIcon = false -}}
|
||||
{{- /* 中国大陆地区无法使用,如果你有更好的 API 或者方案,欢迎 PR! */ -}}
|
||||
{{- $favicon := partial "function/get-remote-image.html" (dict "Path" (add "https://www.google.com/s2/favicons?sz=64&domain=" $url.Host) "Pass" true) -}}
|
||||
{{- if $favicon -}}
|
||||
{{- $cardIcon = $favicon.RelPermalink -}}
|
||||
{{- with $favicon -}}
|
||||
{{- $cardIcon = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user