From 59108fe4585e8b3463a00bcd71fbbd7e5034dbd2 Mon Sep 17 00:00:00 2001 From: ilylia Date: Mon, 9 Dec 2019 23:07:01 +0800 Subject: [PATCH] fix image path invalid on windows (#6021) --- layouts/shortcodes/image.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html index 0f413a43ef..3f314defc2 100644 --- a/layouts/shortcodes/image.html +++ b/layouts/shortcodes/image.html @@ -49,17 +49,17 @@ omit this value and it will be computed automatically. {{- /* Turn relative values for $link into absolute values */ -}} {{- if not (or (hasPrefix $link "/") (hasPrefix $link "https://") (strings.HasPrefix $link "http://")) -}} - {{ $pageDir := .Page.File.Dir }} + {{ $pageDir := path.Dir .Page.File.Path }} {{- if ne .Page.Language.Lang "en" -}} {{- $pageDir = printf "%s/%s" .Page.Language.Lang $pageDir -}} {{- end -}} {{- if (hasPrefix $link "../") -}} - {{- $link = printf "/%s%s" $pageDir (slicestr $link 3) -}} + {{- $link = printf "/%s/%s" $pageDir (slicestr $link 3) -}} {{- else if (hasPrefix $link "./") -}} - {{- $link = printf "/%s%s" $pageDir (slicestr $link 2) -}} + {{- $link = printf "/%s/%s" $pageDir (slicestr $link 2) -}} {{- else -}} - {{- $link = printf "/%s%s" $pageDir $link -}} + {{- $link = printf "/%s/%s" $pageDir $link -}} {{- end -}} {{- end -}}