mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-08 12:07:06 +08:00
fix: 修復主頁滾動, 頂部圖有延遲的 bug closed #1372
fix: 修復當設置搜索文件為xml時,搜索 < 和 > 沒有結果的 bug closed #1369 fix: 修復 CDN 的 custom_format 沒配置,preconnect 報錯的 bug closed #1371
This commit is contained in:
@@ -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]
|
||||
}
|
||||
-
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, '<').replace(/>/g, '>'))
|
||||
if (searchText !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
|
||||
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 = `<div class="search-result-stats">${languages.hits_empty.replace(/\$\{query}/, searchText)}</div>`
|
||||
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 = `<div class="search-result-list">${resultItems.map(result => result.item).join('')}</div>`
|
||||
statsItem.innerHTML = `<hr><div class="search-result-stats">${stats}</div>`
|
||||
window.pjax && window.pjax.refresh(container)
|
||||
|
||||
Reference in New Issue
Block a user