support sub-path(slug)
This commit is contained in:
parent
1bc2c744ff
commit
fe5076c42e
File diff suppressed because one or more lines are too long
|
@ -14,16 +14,33 @@
|
|||
<script>
|
||||
// search
|
||||
var baseurl = null;
|
||||
{{ $siteBaseURL := .Site.BaseURL }}
|
||||
var siteBaseURL = JSON.parse({{ $siteBaseURL | jsonify }});
|
||||
var siteBaseChecker = /\/\w+\//i;
|
||||
var isSlug = siteBaseChecker.test(siteBaseURL);
|
||||
|
||||
var runSearch = function() {
|
||||
{{ if .Site.IsMultiLingual }}
|
||||
var isSubDirDisabled = location.pathname.startsWith("/{{.Site.Language.Lang}}");
|
||||
if (isSubDirDisabled) {
|
||||
baseurl = location.origin + "/{{.Site.Language.Lang}}";
|
||||
var hasLangPostfix = location.pathname.includes("/{{.Site.Language.Lang}}");
|
||||
if (hasLangPostfix) {
|
||||
if (isSlug) {
|
||||
baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0] + "{{.Site.Language.Lang}}";
|
||||
} else {
|
||||
baseurl = location.origin + "/{{.Site.Language.Lang}}";
|
||||
}
|
||||
} else {
|
||||
baseurl = location.origin;
|
||||
if (isSlug) {
|
||||
baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0];
|
||||
} else {
|
||||
baseurl = location.origin;
|
||||
}
|
||||
}
|
||||
{{ else }}
|
||||
baseurl = location.origin;
|
||||
if (isSlug) {
|
||||
baseurl = location.origin + siteBaseURL.match(siteBaseChecker)[0];
|
||||
} else {
|
||||
baseurl = location.origin;
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
var searchResults = null;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<figure {{ with .Get "class" }}class="{{.}}" {{ end }}>
|
||||
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
|
||||
<img data-src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24pt' height='24pt' viewBox='0 0 24 24' version='1.1'%3E%3Cg id='surface1035795'%3E%3Cpath style=' stroke:none;fill-rule:nonzero;fill:rgb(80%25,80%25,80%25);fill-opacity:1;' d='M 4 4 C 2.90625 4 2 4.90625 2 6 L 2 18 C 2 19.09375 2.90625 20 4 20 L 20 20 C 21.09375 20 22 19.09375 22 18 L 22 6 C 22 4.90625 21.09375 4 20 4 Z M 4 6 L 20 6 L 20 18 L 4 18 Z M 4 6 '/%3E%3C/g%3E%3C/svg%3E%0A" class="lazyload" width="{{ .Get "width" }}" height="{{ .Get "height" }}"/>
|
||||
{{ $base := (findRE "/[a-zA-Z0-9_]+/" .Site.BaseURL) }}
|
||||
<img data-src="{{ delimit $base "" }}{{ substr (.Get "src") 1 }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24pt' height='24pt' viewBox='0 0 24 24' version='1.1'%3E%3Cg id='surface1035795'%3E%3Cpath style=' stroke:none;fill-rule:nonzero;fill:rgb(80%25,80%25,80%25);fill-opacity:1;' d='M 4 4 C 2.90625 4 2 4.90625 2 6 L 2 18 C 2 19.09375 2.90625 20 4 20 L 20 20 C 21.09375 20 22 19.09375 22 18 L 22 6 C 22 4.90625 21.09375 4 20 4 Z M 4 6 L 20 6 L 20 18 L 4 18 Z M 4 6 '/%3E%3C/g%3E%3C/svg%3E%0A" class="lazyload" width="{{ .Get "width" }}" height="{{ .Get "height" }}"/>
|
||||
{{ if .Get "link"}}</a>{{ end }}
|
||||
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
|
||||
<figcaption>{{ if isset .Params "title" }}
|
||||
|
|
Loading…
Reference in New Issue