BaseURL problem fixed
This commit is contained in:
parent
2107a1e1d4
commit
1450e07be0
File diff suppressed because one or more lines are too long
|
|
@ -21,7 +21,7 @@ $light: (
|
||||||
navbar-title-color: #555,
|
navbar-title-color: #555,
|
||||||
navbar-title-hover-color: #607d8b,
|
navbar-title-hover-color: #607d8b,
|
||||||
navbar-title-active-color: #FF6188,
|
navbar-title-active-color: #FF6188,
|
||||||
navbar-menu-hover-background-color: lighten(#eeeeee, 1%),
|
navbar-menu-hover-background-color: lighten(#eeeeee, 3%),
|
||||||
navbar-dropdown-item-hover-color: #607d8b,
|
navbar-dropdown-item-hover-color: #607d8b,
|
||||||
sidebar-title-color: #424242,
|
sidebar-title-color: #424242,
|
||||||
sidebar-li-color: #424242,
|
sidebar-li-color: #424242,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"progress": true,
|
"progress": true,
|
||||||
"slideNumber": false,
|
"slideNumber": false,
|
||||||
"hash": false,
|
"hash": false,
|
||||||
"history": false,
|
"history": true,
|
||||||
"keyboard": true,
|
"keyboard": true,
|
||||||
"overview": true,
|
"overview": true,
|
||||||
"center": true,
|
"center": true,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
{{ if .Site.Params.custom_js }}
|
||||||
|
{{ range .Site.Params.custom_js }}
|
||||||
|
{{ $custom_template := resources.Get . }}
|
||||||
|
{{ if $custom_template }}
|
||||||
|
{{ $custom_js := $custom_template | resources.Minify | resources.Fingerprint }}
|
||||||
|
<script defer src="{{ $custom_js.RelPermalink }}"></script>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $fuse := resources.Get "js/fuse.min.js" | resources.Fingerprint }}
|
||||||
|
<script defer src="{{ $fuse.RelPermalink }}"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// search
|
||||||
|
var runSearch = function() {
|
||||||
|
{{ if .Site.IsMultiLingual }}
|
||||||
|
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
|
||||||
|
{{ else }}
|
||||||
|
var baseurl = "{{.Site.BaseURL}}";
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
var searchResults = null;
|
||||||
|
var searchMenu = null;
|
||||||
|
var fuse = null;
|
||||||
|
|
||||||
|
function endsWith(str, suffix) {
|
||||||
|
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initFuse() {
|
||||||
|
if (!endsWith(baseurl, "/")) {
|
||||||
|
baseurl = baseurl + '/';
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: baseurl + "index.json",
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
dataType: "json",
|
||||||
|
})
|
||||||
|
.done(function (index) {
|
||||||
|
fuse = new Fuse(index, {
|
||||||
|
keys: ['title', 'description', 'content']
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.fail(function (jqxhr, textStatus, error) {
|
||||||
|
var err = textStatus + ", " + error;
|
||||||
|
console.error("Error getting Hugo index file:", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSearchResults(results) {
|
||||||
|
searchResults = document.getElementById('search-results');
|
||||||
|
searchMenu = document.getElementById('search-menu');
|
||||||
|
searchResults.setAttribute('class', 'dropdown is-active');
|
||||||
|
|
||||||
|
var content = document.createElement('div');
|
||||||
|
content.setAttribute('class', 'dropdown-content search-content');
|
||||||
|
|
||||||
|
if (results.length > 0) {
|
||||||
|
results.forEach(function (result) {
|
||||||
|
var item = document.createElement('a');
|
||||||
|
item.setAttribute('href', result.uri);
|
||||||
|
item.setAttribute('class', 'dropdown-item');
|
||||||
|
item.innerHTML = `<div class="menu-item"><div class="menu-item__title">📄 ${result.title}</div><div class="menu-item__desc">${result.description ? result.description : result.content}</div></div>`;
|
||||||
|
content.appendChild(item);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var item = document.createElement('span');
|
||||||
|
item.setAttribute('class', 'dropdown-item');
|
||||||
|
item.innerText = 'No results found';
|
||||||
|
content.appendChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (searchMenu.hasChildNodes()) {
|
||||||
|
searchMenu.removeChild(
|
||||||
|
searchMenu.lastChild
|
||||||
|
);
|
||||||
|
}
|
||||||
|
searchMenu.appendChild(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSearchResultsMobile(results) {
|
||||||
|
searchResults = document.getElementById('search-mobile-results');
|
||||||
|
|
||||||
|
var content = document.createElement('div');
|
||||||
|
content.setAttribute('class', 'mobile-search__content');
|
||||||
|
|
||||||
|
if (results.length > 0) {
|
||||||
|
results.forEach(function (result) {
|
||||||
|
var item = document.createElement('a');
|
||||||
|
item.setAttribute('href', result.uri);
|
||||||
|
item.innerHTML = `<div class="mobile-search__item"><div class="mobile-search__item--title">📄 ${result.title}</div><div class="mobile-search__item--desc">${result.description ? result.description : result.content}</div></div>`;
|
||||||
|
content.appendChild(item);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var item = document.createElement('span');
|
||||||
|
content.appendChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#search-mobile-results').empty();
|
||||||
|
searchResults.appendChild(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFuse();
|
||||||
|
|
||||||
|
$("#search").on('input', function (e) {
|
||||||
|
if (!e.target.value) {
|
||||||
|
$('#search-results').attr('class', 'dropdown');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(window).width() < 770) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = fuse.search(e.target.value);
|
||||||
|
renderSearchResults(results);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#search').on('blur', function () {
|
||||||
|
if ($(window).width() < 770) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
$('#search-results').attr('class', 'dropdown');
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#search').on('click', function (e) {
|
||||||
|
if ($(window).width() < 770) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!e.target.value) {
|
||||||
|
$('#search-results').attr('class', 'dropdown');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var results = fuse.search(e.target.value);
|
||||||
|
renderSearchResults(results);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#search').on('keydown', function (e) {
|
||||||
|
if ($(window).width() < 770) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var items = $('#search-menu .dropdown-item');
|
||||||
|
var activeIndex = $('#search-menu .dropdown-item.is-active').index();
|
||||||
|
|
||||||
|
items.removeClass('is-active');
|
||||||
|
if (e.key === 'ArrowDown') {
|
||||||
|
items.eq(activeIndex + 1).addClass('is-active');
|
||||||
|
} else if (e.key === 'ArrowUp') {
|
||||||
|
items.eq(activeIndex - 1).addClass('is-active');
|
||||||
|
} else if (e.key === 'Enter') {
|
||||||
|
var currentItemLink = items.eq(activeIndex).attr('href');
|
||||||
|
if (currentItemLink) {
|
||||||
|
location.href = currentItemLink;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#search-mobile").on('input', function(e) {
|
||||||
|
if (!e.target.value) {
|
||||||
|
$('#search-mobile-results').empty();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = fuse.search(e.target.value);
|
||||||
|
renderSearchResultsMobile(results);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{ block "title" . }}{{ .Title }} – {{ .Site.Title }}{{ end }}</title>
|
<title>{{ block "title" . }}{{ .Title }} – {{ .Site.Title }}{{ end }}</title>
|
||||||
{{ partialCached "head/scripts" . }}
|
{{ partial "head/scripts" . }}
|
||||||
{{ partialCached "head/styles" . }}
|
{{ partialCached "head/styles" . }}
|
||||||
{{ partial "head/meta" . }}
|
{{ partial "head/meta" . }}
|
||||||
{{ partial "head/meta_json_ld" . }}
|
{{ partial "head/meta_json_ld" . }}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
// search
|
// search
|
||||||
var runSearch = function() {
|
var runSearch = function() {
|
||||||
{{ if .Site.IsMultiLingual }}
|
{{ if .Site.IsMultiLingual }}
|
||||||
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
|
var baseurl = location.origin + "/{{.Site.Language.Lang}}";
|
||||||
{{ else }}
|
{{ else }}
|
||||||
var baseurl = "{{.Site.BaseURL}}";
|
var baseurl = location.origin;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
var searchResults = null;
|
var searchResults = null;
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
{{ if $.Param "enableSidebar" }}
|
{{ if $.Param "enableSidebar" }}
|
||||||
|
|
||||||
{{ $currentSection := .Section }}
|
|
||||||
{{ $currentID := "" }}
|
|
||||||
{{ with .File }}{{ $currentID = .UniqueID }}{{ end }}
|
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
{{ partial "search/site-search" . }}
|
{{ partial "search/site-search" . }}
|
||||||
{{ partial "sidebar/custom-list" . }}
|
{{ partial "sidebar/custom-list" . }}
|
||||||
{{ if .Site.Params.itemsPerCategory }}
|
{{ if .Site.Params.itemsPerCategory }}
|
||||||
{{ range first .Site.Params.itemsPerCategory .Pages }}
|
{{ range first .Site.Params.itemsPerCategory .Pages }}
|
||||||
<section class="sidebar-recent">
|
<section class="sidebar-recent">
|
||||||
<a href="{{ .RelPermalink }}" class="sidebar-recent__title p1 {{ if eq $currentSection .Section }}active{{ end }}">{{ .Title }}</a>
|
<a href="{{ .RelPermalink }}" class="sidebar-recent__title p1">{{ .Title }}</a>
|
||||||
<ul class="sidebar-recent__ul">
|
<ul class="sidebar-recent__ul">
|
||||||
{{ range first .Site.Params.itemsPerCategory .Pages }}
|
{{ range first .Site.Params.itemsPerCategory .Pages }}
|
||||||
<li><a href="{{ .RelPermalink }}" class="sidebar-recent__a p2 {{ if eq $currentID .File.UniqueID }}active{{ end }}">{{ .Title }}</a>
|
<li><a href="{{ .RelPermalink }}" class="sidebar-recent__a p2">{{ .Title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue