Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/reuixiy/hugo-theme-meme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMakise Von <v.makise@foxmail.com>2021-11-29 19:21:57 +0300
committerGitHub <noreply@github.com>2021-11-29 19:21:57 +0300
commitd8af0e0d6c89afc4cc79982cb73a8c094cf5ee5e (patch)
tree58ffc53a1f9c6f3473fe8b4aa83165bfb4523fc9
parentadefef8bc638ace1d48a7ce5e75f8c2d9e3e53b3 (diff)
feat: ignore suffix slash of image host (#358)
-rw-r--r--layouts/partials/utils/content.html4
-rw-r--r--layouts/partials/utils/images.html2
2 files changed, 3 insertions, 3 deletions
diff --git a/layouts/partials/utils/content.html b/layouts/partials/utils/content.html
index a1bf70b..05ec4c4 100644
--- a/layouts/partials/utils/content.html
+++ b/layouts/partials/utils/content.html
@@ -113,14 +113,14 @@
<!-- Image Hosting -->
{{- if and .Site.Params.enableImageHost (eq hugo.Environment "production") -}}
- {{- $hostURL := .Site.Params.imageHostURL -}}
+ {{- $hostURL := strings.TrimSuffix "/" .Site.Params.imageHostURL -}}
{{- $temps := findRE `<(img) src="/?([^":]+)` $Content | uniq -}}
{{- with $temps -}}
{{- range . -}}
{{- if not (in (slice "http" "ttps") (substr . -1 4)) -}}
{{- $url := replaceRE `<(img) src="/?([^":]+)` `$2` . -}}
{{- $prefix := replaceRE `(<(img) src=")/?([^":]+)` `$1` . -}}
- {{- $replacement := (printf `%s%s%s` $prefix $hostURL $url) -}}
+ {{- $replacement := (printf `%s%s/%s` $prefix $hostURL $url) -}}
{{- $Content = replace $Content . $replacement -}}
{{- end -}}
{{- end -}}
diff --git a/layouts/partials/utils/images.html b/layouts/partials/utils/images.html
index 5282589..275f46f 100644
--- a/layouts/partials/utils/images.html
+++ b/layouts/partials/utils/images.html
@@ -12,7 +12,7 @@
{{- if and $.Site.Params.enableImageHost $.Site.Params.headAlso -}}
{{- if (eq hugo.Environment "production") -}}
{{- if ne (substr . 0 4) "http" -}}
- {{- $img = printf `%s%s` $.Site.Params.imageHostURL (strings.TrimPrefix "/" $img) -}}
+ {{- $img = printf `%s/%s` (strings.TrimSuffix "/" $.Site.Params.imageHostURL) (strings.TrimPrefix "/" $img) -}}
{{- end -}}
{{- end -}}
{{- end -}}