mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
breaking changes: 升級 fontawesome 到 v6 #689
feat: snackbar 增加圓角 feat: 增加 flink 標籤外掛 fix: 修復點擊 toc 外圍,控制檯報錯的 bug fix: Facebook Comments 無法使用 #787 fix: chat_btn 聊天按鈕翻譯缺失 #791 fix: local search 的 content 設爲 false, 搜索無法運行的 bug #764 fix: Mermaid 圖表渲染後元素高度過大 #773 fix: 文章頁分享按鈕另開一行時, 導航頁寬度沒有 100% 的 bug #765 improvement: 語義化 toggle 標籤外掛 improvement: darkmode 下 toc 背景顏色更改
This commit is contained in:
@@ -361,7 +361,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// toc元素點擊
|
||||
$cardToc.addEventListener('click', e => {
|
||||
e.preventDefault()
|
||||
const $target = e.target.classList.contains('toc-link')
|
||||
const target = e.target.classList
|
||||
if (target.contains('toc-content')) return
|
||||
const $target = target.contains('toc-link')
|
||||
? e.target
|
||||
: e.target.parentElement
|
||||
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300)
|
||||
@@ -613,13 +615,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
$hideInline.forEach(function (item) {
|
||||
item.addEventListener('click', function (e) {
|
||||
const $this = this
|
||||
const $hideContent = $this.nextElementSibling
|
||||
$this.classList.toggle('open')
|
||||
if ($this.classList.contains('open')) {
|
||||
if ($hideContent.querySelectorAll('.fj-gallery').length > 0) {
|
||||
btf.initJustifiedGallery($hideContent.querySelectorAll('.fj-gallery'))
|
||||
}
|
||||
}
|
||||
$this.classList.add('open')
|
||||
const $fjGallery = $this.nextElementSibling.querySelectorAll('.fj-gallery')
|
||||
$fjGallery.length && btf.initJustifiedGallery($fjGallery)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ window.addEventListener('load', () => {
|
||||
datas = [...a.querySelectorAll('entry')].map(function (item) {
|
||||
return {
|
||||
title: item.querySelector('title').textContent,
|
||||
content: item.querySelector('content').textContent,
|
||||
content: item.querySelector('content') && item.querySelector('content').textContent,
|
||||
url: item.querySelector('url').textContent
|
||||
}
|
||||
})
|
||||
@@ -76,15 +76,12 @@ window.addEventListener('load', () => {
|
||||
|
||||
$resultContent.innerHTML = ''
|
||||
let str = '<div class="search-result-list">'
|
||||
if (this.value.trim().length <= 0) return
|
||||
if (keywords.length <= 0) return
|
||||
let count = 0
|
||||
// perform local searching
|
||||
datas.forEach(function (data) {
|
||||
let isMatch = true
|
||||
if (!data.title || data.title.trim() === '') {
|
||||
data.title = ''
|
||||
}
|
||||
let dataTitle = data.title.trim().toLowerCase()
|
||||
let dataTitle = data.title ? data.title.trim().toLowerCase() : ''
|
||||
const dataContent = data.content ? data.content.trim().replace(/<[^>]+>/g, '').toLowerCase() : ''
|
||||
const dataUrl = data.url.startsWith('/') ? data.url : GLOBAL_CONFIG.root + data.url
|
||||
let indexTitle = -1
|
||||
@@ -112,11 +109,10 @@ window.addEventListener('load', () => {
|
||||
|
||||
// show search results
|
||||
if (isMatch) {
|
||||
const content = data.content.trim().replace(/<[^>]+>/g, '')
|
||||
if (firstOccur >= 0) {
|
||||
// cut out 130 characters
|
||||
// let start = firstOccur - 30 < 0 ? 0 : firstOccur - 30
|
||||
// let end = firstOccur + 50 > content.length ? content.length : firstOccur + 50
|
||||
// let end = firstOccur + 50 > dataContent.length ? dataContent.length : firstOccur + 50
|
||||
let start = firstOccur - 30
|
||||
let end = firstOccur + 100
|
||||
|
||||
@@ -128,11 +124,11 @@ window.addEventListener('load', () => {
|
||||
end = 100
|
||||
}
|
||||
|
||||
if (end > content.length) {
|
||||
end = content.length
|
||||
if (end > dataContent.length) {
|
||||
end = dataContent.length
|
||||
}
|
||||
|
||||
let matchContent = content.substring(start, end)
|
||||
let matchContent = dataContent.substring(start, end)
|
||||
|
||||
// highlight all keywords
|
||||
keywords.forEach(function (keyword) {
|
||||
|
||||
@@ -66,7 +66,8 @@ const btf = {
|
||||
backgroundColor: bg,
|
||||
showAction: showAction,
|
||||
duration: duration,
|
||||
pos: position
|
||||
pos: position,
|
||||
customClass: 'snackbar-css'
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user