mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
Merge branch 'dev'
This commit is contained in:
@@ -515,12 +515,12 @@ share:
|
|||||||
# Share.js
|
# Share.js
|
||||||
# https://github.com/overtrue/share.js
|
# https://github.com/overtrue/share.js
|
||||||
sharejs:
|
sharejs:
|
||||||
sites: facebook,twitter,wechat,weibo,qq
|
sites: facebook,x,wechat,weibo,qq
|
||||||
|
|
||||||
# AddToAny
|
# AddToAny
|
||||||
# https://www.addtoany.com/
|
# https://www.addtoany.com/
|
||||||
addtoany:
|
addtoany:
|
||||||
item: facebook,twitter,wechat,sina_weibo,facebook_messenger,email,copy_link
|
item: facebook,x,wechat,sina_weibo,facebook_messenger,email,copy_link
|
||||||
|
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Comments System
|
# Comments System
|
||||||
@@ -1067,7 +1067,7 @@ CDN:
|
|||||||
third_party_provider: jsdelivr
|
third_party_provider: jsdelivr
|
||||||
|
|
||||||
# Add version number to url, true or false
|
# Add version number to url, true or false
|
||||||
version: false
|
version: true
|
||||||
|
|
||||||
# Custom format
|
# Custom format
|
||||||
# For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file}
|
# For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ search:
|
|||||||
pagination:
|
pagination:
|
||||||
prev: 上一篇
|
prev: 上一篇
|
||||||
next: 下一篇
|
next: 下一篇
|
||||||
page_info: '第 ${current} 頁 / 共 ${total} 頁'
|
page_info: '第 ${current} 页 / 共 ${total} 页'
|
||||||
|
|
||||||
comment: 评论
|
comment: 评论
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@
|
|||||||
|
|
||||||
- const localDate = page.shuoshuo_url ? [] : shuoshuoFN(site.data.shuoshuo, page)
|
- const localDate = page.shuoshuo_url ? [] : shuoshuoFN(site.data.shuoshuo, page)
|
||||||
|
|
||||||
|
if !page.shuoshuo_url
|
||||||
|
script(type='application/json' id='shuoshuo-data')!= safeJSON(localDate)
|
||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const limitConfig = !{ JSON.stringify(page.limit || {}) }
|
const limitConfig = !{ JSON.stringify(page.limit || {}) }
|
||||||
@@ -280,7 +283,8 @@
|
|||||||
const response = await fetch('!{url_for(page.shuoshuo_url)}')
|
const response = await fetch('!{url_for(page.shuoshuo_url)}')
|
||||||
originData = await response.json()
|
originData = await response.json()
|
||||||
} else {
|
} else {
|
||||||
originData = !{JSON.stringify(localDate)}
|
const dataElement = document.getElementById('shuoshuo-data')
|
||||||
|
originData = dataElement ? JSON.parse(dataElement.textContent) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
data = filterDataByLimit(sortDataByDate(originData), limitConfig)
|
data = filterDataByLimit(sortDataByDate(originData), limitConfig)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "5.5.0",
|
"version": "5.5.1",
|
||||||
"description": "A Simple and Card UI Design theme for Hexo",
|
"description": "A Simple and Card UI Design theme for Hexo",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
18
plugins.yml
18
plugins.yml
@@ -9,7 +9,7 @@ activate_power_mode:
|
|||||||
algolia_search:
|
algolia_search:
|
||||||
name: algoliasearch
|
name: algoliasearch
|
||||||
file: dist/lite/builds/browser.umd.js
|
file: dist/lite/builds/browser.umd.js
|
||||||
version: 5.37.0
|
version: 5.39.0
|
||||||
aplayer_css:
|
aplayer_css:
|
||||||
name: aplayer
|
name: aplayer
|
||||||
file: dist/APlayer.min.css
|
file: dist/APlayer.min.css
|
||||||
@@ -57,21 +57,21 @@ click_heart:
|
|||||||
disqusjs:
|
disqusjs:
|
||||||
name: disqusjs
|
name: disqusjs
|
||||||
file: dist/browser/disqusjs.es2015.umd.min.js
|
file: dist/browser/disqusjs.es2015.umd.min.js
|
||||||
version: 3.1.0
|
version: 3.1.1
|
||||||
disqusjs_css:
|
disqusjs_css:
|
||||||
name: disqusjs
|
name: disqusjs
|
||||||
file: dist/browser/styles/disqusjs.css
|
file: dist/browser/styles/disqusjs.css
|
||||||
version: 3.1.0
|
version: 3.1.1
|
||||||
docsearch_css:
|
docsearch_css:
|
||||||
name: '@docsearch/css'
|
name: '@docsearch/css'
|
||||||
other_name: docsearch-css
|
other_name: docsearch-css
|
||||||
file: dist/style.css
|
file: dist/style.css
|
||||||
version: 3.9.0
|
version: 4.1.0
|
||||||
docsearch_js:
|
docsearch_js:
|
||||||
name: '@docsearch/js'
|
name: '@docsearch/js'
|
||||||
other_name: docsearch-js
|
other_name: docsearch-js
|
||||||
file: dist/umd/index.js
|
file: dist/umd/index.js
|
||||||
version: 3.9.0
|
version: 4.1.0
|
||||||
egjs_infinitegrid:
|
egjs_infinitegrid:
|
||||||
name: '@egjs/infinitegrid'
|
name: '@egjs/infinitegrid'
|
||||||
other_name: egjs-infinitegrid
|
other_name: egjs-infinitegrid
|
||||||
@@ -80,12 +80,12 @@ egjs_infinitegrid:
|
|||||||
fancybox:
|
fancybox:
|
||||||
name: '@fancyapps/ui'
|
name: '@fancyapps/ui'
|
||||||
file: dist/fancybox/fancybox.umd.js
|
file: dist/fancybox/fancybox.umd.js
|
||||||
version: 6.0.29
|
version: 6.0.33
|
||||||
other_name: fancyapps-ui
|
other_name: fancyapps-ui
|
||||||
fancybox_css:
|
fancybox_css:
|
||||||
name: '@fancyapps/ui'
|
name: '@fancyapps/ui'
|
||||||
file: dist/fancybox/fancybox.css
|
file: dist/fancybox/fancybox.css
|
||||||
version: 6.0.29
|
version: 6.0.33
|
||||||
other_name: fancyapps-ui
|
other_name: fancyapps-ui
|
||||||
fireworks:
|
fireworks:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
@@ -95,7 +95,7 @@ fontawesome:
|
|||||||
name: '@fortawesome/fontawesome-free'
|
name: '@fortawesome/fontawesome-free'
|
||||||
file: css/all.min.css
|
file: css/all.min.css
|
||||||
other_name: font-awesome
|
other_name: font-awesome
|
||||||
version: 7.0.1
|
version: 7.1.0
|
||||||
gitalk:
|
gitalk:
|
||||||
name: gitalk
|
name: gitalk
|
||||||
file: dist/gitalk.min.js
|
file: dist/gitalk.min.js
|
||||||
@@ -133,7 +133,7 @@ medium_zoom:
|
|||||||
mermaid:
|
mermaid:
|
||||||
name: mermaid
|
name: mermaid
|
||||||
file: dist/mermaid.min.js
|
file: dist/mermaid.min.js
|
||||||
version: 11.11.0
|
version: 11.12.0
|
||||||
meting_js:
|
meting_js:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: metingjs/dist/Meting.min.js
|
file: metingjs/dist/Meting.min.js
|
||||||
|
|||||||
@@ -290,10 +290,10 @@ module.exports = {
|
|||||||
share: {
|
share: {
|
||||||
use: 'sharejs',
|
use: 'sharejs',
|
||||||
sharejs: {
|
sharejs: {
|
||||||
sites: 'facebook,twitter,wechat,weibo,qq'
|
sites: 'facebook,x,wechat,weibo,qq'
|
||||||
},
|
},
|
||||||
addtoany: {
|
addtoany: {
|
||||||
item: 'facebook,twitter,wechat,sina_weibo,facebook_messenger,email,copy_link'
|
item: 'facebook,x,wechat,sina_weibo,facebook_messenger,email,copy_link'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
comments: {
|
comments: {
|
||||||
@@ -591,7 +591,7 @@ module.exports = {
|
|||||||
CDN: {
|
CDN: {
|
||||||
internal_provider: 'local',
|
internal_provider: 'local',
|
||||||
third_party_provider: 'jsdelivr',
|
third_party_provider: 'jsdelivr',
|
||||||
version: false,
|
version: true,
|
||||||
custom_format: null,
|
custom_format: null,
|
||||||
option: null
|
option: null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,20 +18,12 @@ const lazyload = htmlContent => {
|
|||||||
|
|
||||||
const bg = hexo.theme.config.lazyload.placeholder ? urlFor(hexo.theme.config.lazyload.placeholder) : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
const bg = hexo.theme.config.lazyload.placeholder ? urlFor(hexo.theme.config.lazyload.placeholder) : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
||||||
|
|
||||||
// Use more precise replacement: handle src attributes with double and single quotes, but avoid replacing content inside script tags
|
// Handle src attributes with double quotes, single quotes, or no quotes (unified approach)
|
||||||
let result = htmlContent
|
// Matches: src="..." or src='...' or src=... (e.g., after minification by hexo-minify)
|
||||||
|
return htmlContent.replace(/(<img(?![^>]*?\bdata-lazy-src=)(?:\s[^>]*?)?\ssrc=)(?:"([^"]*)"|'([^']*)'|([^\s>]+))(?![^<]*<\/script>)/gi, (match, prefix, srcDoubleQuote, srcSingleQuote, srcNoQuote) => {
|
||||||
// Handle src attributes with double quotes
|
const src = srcDoubleQuote || srcSingleQuote || srcNoQuote
|
||||||
result = result.replace(/(<img(?![^>]*?\bdata-lazy-src=)(?:\s[^>]*?)?\ssrc="([^"]+)")(?![^<]*<\/script>)/gi, (match, tag, src) => {
|
return `${prefix}"${bg}" data-lazy-src="${src}"`
|
||||||
return tag.replace(`src="${src}"`, `src="${bg}" data-lazy-src="${src}"`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle src attributes with single quotes
|
|
||||||
result = result.replace(/(<img(?![^>]*?\bdata-lazy-src=)(?:\s[^>]*?)?\ssrc='([^']+)')(?![^<]*<\/script>)/gi, (match, tag, src) => {
|
|
||||||
return tag.replace(`src='${src}'`, `src='${bg}' data-lazy-src='${src}'`)
|
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.filter.register('after_render:html', data => {
|
hexo.extend.filter.register('after_render:html', data => {
|
||||||
|
|||||||
@@ -157,3 +157,12 @@ hexo.extend.helper.register('getVersion', () => {
|
|||||||
const { version } = require('../../package.json')
|
const { version } = require('../../package.json')
|
||||||
return { hexo: hexo.version, theme: version }
|
return { hexo: hexo.version, theme: version }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hexo.extend.helper.register('safeJSON', data => {
|
||||||
|
// Safely serialize JSON for embedding in <script> tags
|
||||||
|
return JSON.stringify(data)
|
||||||
|
.replace(/</g, '\\u003c')
|
||||||
|
.replace(/>/g, '\\u003e')
|
||||||
|
.replace(/\u2028/g, '\\u2028')
|
||||||
|
.replace(/\u2029/g, '\\u2029')
|
||||||
|
})
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
justify-content: center
|
justify-content: center
|
||||||
align-items: center
|
align-items: center
|
||||||
margin-right: 6px
|
margin-right: 6px
|
||||||
|
margin-top: 3px
|
||||||
min-width: 24px
|
min-width: 24px
|
||||||
color: $search-color
|
color: $search-color
|
||||||
content: attr(value) '.'
|
content: attr(value) '.'
|
||||||
|
|||||||
@@ -156,10 +156,10 @@ class LocalSearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
slicesOfContent.forEach(slice => {
|
slicesOfContent.forEach(slice => {
|
||||||
resultItem += `<p class="search-result">${this.highlightKeyword(content, slice)}...</p></a>`
|
resultItem += `<p class="search-result">${this.highlightKeyword(content, slice)}...</p>`
|
||||||
})
|
})
|
||||||
|
|
||||||
resultItem += '</li>'
|
resultItem += '</a></li>'
|
||||||
resultItems.push({
|
resultItems.push({
|
||||||
item: resultItem,
|
item: resultItem,
|
||||||
id: resultItems.length,
|
id: resultItems.length,
|
||||||
|
|||||||
Reference in New Issue
Block a user