mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
breaking change: 重構 gallery 標籤外掛
improvement: 首頁社交圖標左右邊距調整 feat: 文章版權增加圖標 improvement: 重構 main.js 代碼 improvement: 優化 pjax 下的性能 fix: 修復子目錄下,pjax 跳轉 404 錯誤 feat: getScript 增加 attribute 配置 improvement: 優化手機端 toc 打開和關閉特效 improvement: 文章進入特效改為 transform, 優化 stylus improvement: 目錄側邊欄出現滾動條時,元素不會被擠壓 feat: 文章左右對齊 improvement: 處理 waline 的 url 後面多 / 導致跨域的問題 fix: 修復夜間模式下,小屏幕的toc 滾動條顏色不明顯的 bug fix: 修復設置字體超過17px時,toc 裏面的邊框異常的 bug improvement: 優化語言文件部分用詞 improvement: disqus 和 disqusjs 的評論數獲取不到時,顯示為 0 improvement: disqusjs 的評論數改為 api 獲取 improvement: 代碼優化 improvement: 更新 plugins.yml
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
* Butterfly
|
||||
* galleryGroup and gallery
|
||||
* {% galleryGroup [name] [descr] [url] [img] %}
|
||||
* {% gallery [lazyload],[rowHeight],[limit] %}
|
||||
* {% gallery url,[url],[lazyload],[rowHeight],[limit] %}
|
||||
*
|
||||
* {% gallery [button],%}
|
||||
* {% gallery url,[url],[button]%}
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
@@ -11,14 +12,15 @@
|
||||
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||
|
||||
const gallery = (args, content) => {
|
||||
const { data, languages } = hexo.theme.i18n
|
||||
args = args.join(' ').split(',')
|
||||
let rowHeight, limit, lazyload, type, dataStr
|
||||
let button = false
|
||||
let type = 'data'
|
||||
let dataStr = ''
|
||||
|
||||
if (args[0] === 'url') {
|
||||
[type, dataStr, lazyload, rowHeight = 220, limit = 10] = args // url,[link],[lazyload],[rowHeight],[limit]
|
||||
[type, dataStr, button] = args // url,[link],[lazyload]
|
||||
} else {
|
||||
[lazyload, rowHeight = 220, limit = 10] = args // [lazyload],[rowHeight],[limit]
|
||||
[button] = args // [lazyload]
|
||||
const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
|
||||
let m
|
||||
const arr = []
|
||||
@@ -36,14 +38,10 @@ const gallery = (args, content) => {
|
||||
dataStr = JSON.stringify(arr)
|
||||
}
|
||||
|
||||
type = type ? ' url' : ' data'
|
||||
const lazyloadClass = lazyload === 'true' ? 'lazyload' : ''
|
||||
|
||||
return `<div class="gallery">
|
||||
<div class="fj-gallery ${lazyloadClass + type}" data-rowHeight="${rowHeight}" data-limit="${limit}">
|
||||
<span class="gallery-data">${dataStr}</span>
|
||||
</div>
|
||||
<button class="gallery-load-more"><span>${data[languages[0]].load_more}</span><i class="fa-solid fa-arrow-down"></i></button>
|
||||
return `<div class="gallery-container" data-type="${type}" data-button="${button}">
|
||||
<div class="gallery-data">${dataStr}</div>
|
||||
<div class="gallery-items">
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
@@ -52,8 +50,7 @@ const galleryGroup = args => {
|
||||
const imgUrl = urlFor(img)
|
||||
const urlLink = urlFor(url)
|
||||
|
||||
return `
|
||||
<figure class="gallery-group">
|
||||
return `<figure class="gallery-group">
|
||||
<img class="gallery-group-img no-lightbox" src='${imgUrl}' alt="Group Image Gallery">
|
||||
<figcaption>
|
||||
<div class="gallery-group-name">${name}</div>
|
||||
|
||||
@@ -16,6 +16,7 @@ const postTabs = (args, content) => {
|
||||
let tabId = 0
|
||||
let tabNav = ''
|
||||
let tabContent = ''
|
||||
let noDefault = true
|
||||
|
||||
!tabName && hexo.log.warn('Tabs block must have unique name!')
|
||||
|
||||
@@ -41,17 +42,21 @@ const postTabs = (args, content) => {
|
||||
const icon = tabIcon.trim()
|
||||
tabIcon.length > 0 && (tabIcon = `<i class="${icon}"${isOnlyicon}></i>`)
|
||||
|
||||
const toTop = '<button type="button" class="tab-to-top" aria-label="scroll to top"><i class="fas fa-arrow-up"></i></button>'
|
||||
|
||||
const isActive = (tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1) ? ' active' : ''
|
||||
tabNav += `<li class="tab${isActive}"><button type="button" data-href="#${tabHref}">${tabIcon + tabCaption.trim()}</button></li>`
|
||||
tabContent += `<div class="tab-item-content${isActive}" id="${tabHref}">${postContent + toTop}</div>`
|
||||
let isActive = ''
|
||||
if ((tabActive > 0 && tabActive === tabId) || (tabActive === 0 && tabId === 1)) {
|
||||
isActive = ' active'
|
||||
noDefault = false
|
||||
}
|
||||
tabNav += `<button type="button" class="tab ${isActive}" data-href="${tabHref}">${tabIcon + tabCaption.trim()}</button>`
|
||||
tabContent += `<div class="tab-item-content${isActive}" id="${tabHref}">${postContent}</div>`
|
||||
}
|
||||
|
||||
tabNav = `<ul class="nav-tabs">${tabNav}</ul>`
|
||||
const toTop = '<div class="tab-to-top"><button type="button" aria-label="scroll to top"><i class="fas fa-arrow-up"></i></button></div>'
|
||||
|
||||
tabNav = `<ul class="nav-tabs${noDefault ? ' no-default' : ''}">${tabNav}</ul>`
|
||||
tabContent = `<div class="tab-contents">${tabContent}</div>`
|
||||
|
||||
return `<div class="tabs" id="${tabName.toLowerCase().split(' ').join('-')}">${tabNav + tabContent}</div>`
|
||||
return `<div class="tabs" id="${tabName.toLowerCase().split(' ').join('-')}">${tabNav + tabContent + toTop}</div>`
|
||||
}
|
||||
|
||||
hexo.extend.tag.register('tabs', postTabs, { ends: true })
|
||||
|
||||
Reference in New Issue
Block a user