fix image path invalid on windows (#6021)

This commit is contained in:
ilylia 2019-12-09 23:07:01 +08:00 committed by Istio Automation
parent c84e80f974
commit 59108fe458
1 changed files with 4 additions and 4 deletions

View File

@ -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 -}}