fix: wrong URL of JS and CSS files on baseURL (#249)

This commit is contained in:
Dillon
2020-04-22 21:34:38 +08:00
committed by GitHub
parent 3c38d54a87
commit f5fb31ec43
11 changed files with 33 additions and 21 deletions

View File

@@ -2,15 +2,15 @@
{{- $loading := resources.Get "svg/loading/normal.svg" | minify -}}
{{- $small := .src_s | default .src -}}
{{- $large := .src_l | default .src -}}
{{- $alt := .alt | default .src -}}
{{- $alt := .alt | default (relURL .src) -}}
{{- if .linked -}}
<a class="lightgallery" href="{{ $large | safeURL }}" title="{{ .title | default $alt }}" data-thumbnail="{{ $small | safeURL }}"{{ with .caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.alt }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .rel }} rel="{{ . }}"{{ end }}>
<a class="lightgallery" href="{{ $large | relURL }}" title="{{ .title | default $alt }}" data-thumbnail="{{ $small | relURL }}"{{ with .caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.alt }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .rel }} rel="{{ . }}"{{ end }}>
<img
class="lazyload"
src="{{ $loading.RelPermalink | safeURL }}"
src="{{ $loading.RelPermalink }}"
data-sizes="auto"
data-srcset="{{ $small | safeURL }}, {{ .src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ .src | safeURL }}"
data-srcset="{{ $small | relURL }}, {{ .src | relURL }} 1.5x, {{ $large | relURL }} 2x"
data-src="{{ .src | relURL }}"
alt="{{ $alt }}"{{ with .height }} height="{{ . }}"{{ end }}{{ with .width }} width="{{ . }}"{{ end }} />
</a>
{{- else -}}
@@ -21,8 +21,8 @@
class="lazyload"
src="{{ $loading.RelPermalink | safeURL }}"
data-sizes="auto"
data-srcset="{{ $small | safeURL }}, {{ .src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ .src | safeURL }}"
data-srcset="{{ $small | relURL }}, {{ .src | relURL }} 1.5x, {{ $large | relURL }} 2x"
data-src="{{ .src | relURL }}"
alt="{{ $alt }}"
title="{{ .title | default $alt }}"{{ with .height }} height="{{ . }}"{{ end }}{{ with .width }} width="{{ . }}"{{ end }} />
{{- end -}}

View File

@@ -1,5 +1,5 @@
{{- $rel := "" -}}
<a href="{{ .href | safeURL }}"{{ with .title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .href "http" }}{{ $rel = "noopener noreffer" }} target="_blank"{{ end }} rel="{{ $rel }}{{ with .rel }} {{ . }}{{ end }}"{{ with .class }} class="{{ . }}"{{ end }}>
<a href="{{ .href }}"{{ with .title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .href "http" }}{{ $rel = "noopener noreffer" }} target="_blank"{{ end }} rel="{{ $rel }}{{ with .rel }} {{ . }}{{ end }}"{{ with .class }} class="{{ . }}"{{ end }}>
{{- with .icon -}}
{{- partial "plugin/icon.html" . -}}
{{- end -}}

View File

@@ -3,7 +3,7 @@
{{- else -}}
{{- $src := .source -}}
{{- $integrity := .integrity -}}
{{- if strings.HasPrefix $src "http" | or (strings.HasPrefix $src "||") | not -}}
{{- if strings.HasPrefix $src "http" | or (strings.HasPrefix $src "//") | not -}}
{{- $res := resources.Get $src -}}
{{- with .template -}}
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}