mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
breaking changes: cover 的顯示優化 #1101
feature: default_cover 可配置顏色 fix: 修復使用本地搜索時,輸入特殊符號沒有顯示結果的 bug closed #1110 fix: 修復 頂部圖和 footer 配置帶有/的顏色參數時,無法顯示顏色的 bug improvement: 鼠標移動到分頁時,文章分頁按鈕增加説明文字 improvement: 文章頁的頂部圖顯示次序為 top_img > cover > default_top_img improvement: canonical 的鏈接根據配置生成 #1111
This commit is contained in:
@@ -84,8 +84,11 @@ window.addEventListener('load', () => {
|
||||
$input.addEventListener('input', function () {
|
||||
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
||||
if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
|
||||
else {
|
||||
$resultContent.innerHTML = ''
|
||||
return
|
||||
}
|
||||
|
||||
$resultContent.innerHTML = ''
|
||||
let str = '<div class="search-result-list">'
|
||||
if (keywords.length <= 0) return
|
||||
let count = 0
|
||||
@@ -150,7 +153,12 @@ window.addEventListener('load', () => {
|
||||
|
||||
// highlight all keywords
|
||||
keywords.forEach(keyword => {
|
||||
const regS = new RegExp(keyword, 'gi')
|
||||
let regexStr = keyword
|
||||
const specialRegex = new RegExp("[^\\w\\s]+") // match special characters
|
||||
if (keyword.length === 1 && specialRegex.test(keyword)) {
|
||||
regexStr = `\\${keyword}`
|
||||
}
|
||||
const regS = new RegExp(regexStr, 'gi')
|
||||
matchContent = matchContent.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
||||
dataTitle = dataTitle.replace(regS, '<span class="search-keyword">' + keyword + '</span>')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user