diff --git a/layout/includes/head/preconnect.pug b/layout/includes/head/preconnect.pug index 9eca808..f8af380 100644 --- a/layout/includes/head/preconnect.pug +++ b/layout/includes/head/preconnect.pug @@ -4,7 +4,7 @@ 'jsdelivr': '//cdn.jsdelivr.net', 'cdnjs': '//cdnjs.cloudflare.com', 'unpkg': '//unpkg.com', - 'custom': custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1] + 'custom': custom_format && custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1] } - diff --git a/layout/includes/third-party/search/local-search.pug b/layout/includes/third-party/search/local-search.pug index 0c7537b..f22f05b 100644 --- a/layout/includes/third-party/search/local-search.pug +++ b/layout/includes/third-party/search/local-search.pug @@ -15,7 +15,7 @@ .local-search-box input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input hr - #local-search-results.no-result + #local-search-results #local-search-stats-wrap #search-mask diff --git a/package.json b/package.json index f768fb2..9daa55f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.10.0-b2", + "version": "4.10.0-b3", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/source/css/_global/function.styl b/source/css/_global/function.styl index d89f28d..9a4fa3c 100644 --- a/source/css/_global/function.styl +++ b/source/css/_global/function.styl @@ -134,7 +134,7 @@ if hexo-config('enter_transitions') #footer animation: bottom-top 1s - #page-header + #page-header:not(.full_page) animation: header-effect 1s #site-title, diff --git a/source/css/_search/local-search.styl b/source/css/_search/local-search.styl index f5c5fa9..c8dfdfe 100644 --- a/source/css/_search/local-search.styl +++ b/source/css/_search/local-search.styl @@ -64,10 +64,6 @@ +maxWidth768() max-height: calc(var(--search-height) - 220px) !important - .no-result - & + #local-search-stats-wrap - display: none - .search-keyword background: transparent color: $search-keyword-highlight diff --git a/source/js/search/local-search.js b/source/js/search/local-search.js index 0fbd232..0eecff6 100644 --- a/source/js/search/local-search.js +++ b/source/js/search/local-search.js @@ -246,10 +246,12 @@ window.addEventListener('load', () => { const input = document.querySelector('#local-search-input input') const statsItem = document.getElementById('local-search-stats-wrap') const $loadingStatus = document.getElementById('loading-status') + const isXml = !path.endsWith('json') const inputEventFunction = () => { if (!localSearch.isfetched) return - const searchText = input.value.trim().toLowerCase() + let searchText = input.value.trim().toLowerCase() + isXml && (searchText = searchText.replace(//g, '>')) if (searchText !== '') $loadingStatus.innerHTML = '' const keywords = searchText.split(/[-\s]+/) const container = document.getElementById('local-search-results') @@ -259,11 +261,14 @@ window.addEventListener('load', () => { resultItems = localSearch.getResultItems(keywords) } if (keywords.length === 1 && keywords[0] === '') { - container.classList.add('no-result') container.textContent = '' + statsItem.textContent = '' } else if (resultItems.length === 0) { container.textContent = '' - statsItem.innerHTML = `
${languages.hits_empty.replace(/\$\{query}/, searchText)}
` + const statsDiv = document.createElement('div') + statsDiv.className = 'search-result-stats' + statsDiv.textContent = languages.hits_empty.replace(/\$\{query}/, searchText) + statsItem.innerHTML = statsDiv.outerHTML } else { resultItems.sort((left, right) => { if (left.includedCount !== right.includedCount) { @@ -276,7 +281,6 @@ window.addEventListener('load', () => { const stats = languages.hits_stats.replace(/\$\{hits}/, resultItems.length) - container.classList.remove('no-result') container.innerHTML = `
${resultItems.map(result => result.item).join('')}
` statsItem.innerHTML = `
${stats}
` window.pjax && window.pjax.refresh(container)