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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 21 deletions

View file

@ -7,7 +7,7 @@
<h1 id="error-emoji"></h1>
<p class="error-text">
{{- T "pageNotFoundText" -}}&nbsp;
<a href="{{ `/` | relLangURL }}" title="{{ T `backToHome` }}">↩︎</a>
<a href="{{ .Site.Home.RelPermalink }}" title="{{ T `backToHome` }}">↩︎</a>
</p>
</div>
<script type="text/javascript">

View file

@ -16,7 +16,7 @@
{{- /* Meta */ -}}
<div class="post-meta">
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default (relLangURL "/") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
<span class="post-author">
{{- $options := dict "class" "author" "href" $authorLink "title" "Author" "rel" "author" "icon" (dict "class" "fas fa-user-circle fa-fw") "content" $author -}}
{{- partial "plugin/link.html" $options -}}

View file

@ -64,7 +64,7 @@
<div id="fb-root" class="comment"></div>
<div
class="fb-comments"
data-href="{{ .Permalink | absURL }}"
data-href="{{ .Permalink }}"
data-width="{{ $comment.facebook.width }}"
data-numposts="{{ $comment.facebook.numPosts }}"
></div>

View file

@ -31,7 +31,7 @@
{{- /* Author */ -}}
{{- if ne .Site.Params.footer.author false -}}
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Author.link | default (relLangURL `/`) }}" target="_blank">{{ .Site.Author.name }}</a></span>
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Author.link | default .Site.Home.RelPermalink }}" target="_blank">{{ .Site.Author.name }}</a></span>
{{- end -}}
{{- /* License */ -}}

View file

@ -2,14 +2,20 @@
<header class="desktop" id="header-desktop">
<div class="header-wrapper">
<div class="header-title">
<a href="{{ `/` | relLangURL }}">
<a href="{{ .Site.Home.RelPermalink }}">
{{- .Site.Title -}}
</a>
</div>
<div class="menu">
<div class="menu-inner">
{{- range .Site.Menus.main -}}
<a class="menu-item{{ if $.IsMenuCurrent "main" . | or ($.HasMenuCurrent "main" .) | or (.URL | relLangURL | string | eq $.RelPermalink ) }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ with .Title }} title="{{ . }}"{{ end }} rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
{{- $url := "" -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}}
<a class="menu-item{{ if $.IsMenuCurrent `main` . | or ($.HasMenuCurrent `main` .) | or (eq $.RelPermalink $url) }} active{{ end }}" href="{{ $url }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- .Pre | safeHTML }}{{ .Name -}}
</a>
{{- end -}}
@ -61,7 +67,7 @@
<div class="header-container">
<div class="header-wrapper">
<div class="header-title">
<a href="{{ `/` | relLangURL }}">
<a href="{{ .Site.Home.RelPermalink }}">
{{- .Site.Title -}}
</a>
</div>
@ -91,7 +97,13 @@
{{- end -}}
{{- $currentPage := . -}}
{{- range .Site.Menus.main -}}
<a class="menu-item" href="{{ .URL | relLangURL }}" title="{{ .Title }}" rel="noopener noreffer"{{ if strings.HasPrefix .URL "http" }} target="_blank"{{ end }}>
{{- $url := "" -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}}
<a class="menu-item" href="{{ $url }}" title="{{ .Title }}"{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- .Pre | safeHTML }}{{ .Name -}}
</a>
{{- end -}}

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

View file

@ -53,7 +53,7 @@
{{- end -}}
</section>
<section>
<span><a href="javascript:window.history.back();">{{ T "back" }}</a></span>&nbsp;|&nbsp;<span><a href="{{ `/` | relLangURL }}">{{ T "home" }}</a></span>
<span><a href="javascript:window.history.back();">{{ T "back" }}</a></span>&nbsp;|&nbsp;<span><a href="{{ .Site.Home.RelPermalink }}">{{ T "home" }}</a></span>
</section>
</div>

View file

@ -24,7 +24,7 @@
<div class="post-meta">
<div class="post-meta-line">
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default (relLangURL "/") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
<span class="post-author">
{{- $options := dict "class" "author" "href" $authorLink "title" "Author" "rel" "author" "icon" (dict "class" "fas fa-user-circle fa-fw") "content" $author -}}
{{- partial "plugin/link.html" $options -}}
@ -50,7 +50,7 @@
<i class="far fa-clock fa-fw"></i>{{ T "readingTime" .ReadingTime }}&nbsp;
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
<span id="{{ .RelPermalink | relURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i><span class=leancloud-visitors-count></span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- end -}}

View file

@ -61,4 +61,4 @@ Disallow: /
User-agent: ZoominfoBot
Disallow: /
Sitemap: {{ "sitemap.xml" | absLangURL }}
Sitemap: {{ "/sitemap.xml" | absLangURL }}