mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
update
This commit is contained in:
12
_config.yml
12
_config.yml
@@ -928,16 +928,16 @@ chartjs:
|
|||||||
# The default settings are only used when the MD syntax is not specified.
|
# The default settings are only used when the MD syntax is not specified.
|
||||||
# General font color for the chart
|
# General font color for the chart
|
||||||
fontColor:
|
fontColor:
|
||||||
light: "rgba(0, 0, 0, 0.8)"
|
light: 'rgba(0, 0, 0, 0.8)'
|
||||||
dark: "rgba(255, 255, 255, 0.8)"
|
dark: 'rgba(255, 255, 255, 0.8)'
|
||||||
# General border color for the chart
|
# General border color for the chart
|
||||||
borderColor:
|
borderColor:
|
||||||
light: "rgba(0, 0, 0, 0.1)"
|
light: 'rgba(0, 0, 0, 0.1)'
|
||||||
dark: "rgba(255, 255, 255, 0.2)"
|
dark: 'rgba(255, 255, 255, 0.2)'
|
||||||
# Background color for scale labels on radar and polar area charts
|
# Background color for scale labels on radar and polar area charts
|
||||||
scale_ticks_backdropColor:
|
scale_ticks_backdropColor:
|
||||||
light: "transparent"
|
light: 'transparent'
|
||||||
dark: "transparent"
|
dark: 'transparent'
|
||||||
|
|
||||||
# Note - Bootstrap Callout
|
# Note - Bootstrap Callout
|
||||||
note:
|
note:
|
||||||
|
|||||||
@@ -23,5 +23,6 @@ script#config-diff.
|
|||||||
isHome: !{is_home()},
|
isHome: !{is_home()},
|
||||||
isHighlightShrink: !{isHighlightShrink},
|
isHighlightShrink: !{isHighlightShrink},
|
||||||
isToc: !{showToc},
|
isToc: !{showToc},
|
||||||
postUpdate: '!{full_date(page.updated)}'
|
postUpdate: '!{full_date(page.updated)}',
|
||||||
|
isShuoshuo: !{page.type == 'shuoshuo'}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,127 +6,180 @@
|
|||||||
//- - tag1
|
//- - tag1
|
||||||
//- - tag2
|
//- - tag2
|
||||||
|
|
||||||
|
|
||||||
- page.comments = false
|
|
||||||
- page.toc = false
|
- page.toc = false
|
||||||
|
|
||||||
#article-container
|
#article-container
|
||||||
|
if page.comments !== false && theme.comments.use
|
||||||
|
- commentsJsLoad = true
|
||||||
|
|
||||||
|
script.
|
||||||
|
(() => {
|
||||||
|
const commentDiv = `!{partial('includes/third-party/comments/index', {}, {cache: true})}`
|
||||||
|
|
||||||
|
const runDestroy = (shuoshuoComment) => {
|
||||||
|
if (!shuoshuoComment) return
|
||||||
|
|
||||||
|
for (const [key, fn] of Object.entries(shuoshuoComment)) {
|
||||||
|
if (key.startsWith('destroy')) fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addCommentToShuoshuo = e => {
|
||||||
|
const btn = e.target.closest('.shuoshuo-comment-btn')
|
||||||
|
if (!btn) return
|
||||||
|
|
||||||
|
const ele = btn.parentNode.nextElementSibling
|
||||||
|
const { shuoshuoComment } = window
|
||||||
|
const isInclude = ele.classList.contains('no-comment')
|
||||||
|
runDestroy(shuoshuoComment)
|
||||||
|
if (isInclude) {
|
||||||
|
ele.classList.remove('no-comment')
|
||||||
|
ele.innerHTML = commentDiv
|
||||||
|
const key = `${location.pathname.replace(/\/$/, '')}?key=${ele.getAttribute('data-key')}`
|
||||||
|
btf.switchComments(ele, key)
|
||||||
|
shuoshuoComment.loadComment && shuoshuoComment.loadComment(ele, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
if page.shuoshuo_url
|
if page.shuoshuo_url
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
const limitConfig = !{ JSON.stringify(page.limit || {}) }
|
||||||
|
|
||||||
|
const sortDataByDate = data => data.sort((a, b) => new Date(b.date) - new Date(a.date))
|
||||||
|
|
||||||
|
const filterDataByLimit = (data, limit) => {
|
||||||
|
if (!limit || !limit.type) return data
|
||||||
|
if (limit.type === 'num') return data.slice(0, limit.value)
|
||||||
|
if (limit.type === 'date') {
|
||||||
|
const limitDate = new Date(limit.value)
|
||||||
|
return data.filter(item => new Date(item.date) >= limitDate)
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatToTimeZone = (date) => {
|
||||||
|
const fullDate = date.length === 10 ? `${date} 00:00:00` : date
|
||||||
|
const visitorTimeZone = '#{config.timezone}' || Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||||
|
const options = {
|
||||||
|
timeZone: visitorTimeZone,
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
hour12: false
|
||||||
|
}
|
||||||
|
const [day, month, year, hour, minute, second] = new Intl.DateTimeFormat('en-GB', options)
|
||||||
|
.format(new Date(fullDate))
|
||||||
|
.match(/\d+/g)
|
||||||
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
|
||||||
|
}
|
||||||
|
|
||||||
const loadShuoshuo = async () => {
|
const loadShuoshuo = async () => {
|
||||||
try {
|
try {
|
||||||
const fetchContent = await fetch('!{url_for(page.shuoshuo_url)}')
|
const response = await fetch('!{url_for(page.shuoshuo_url)}')
|
||||||
const shuoshuo = await fetchContent.json()
|
let data = await response.json()
|
||||||
|
|
||||||
|
data = filterDataByLimit(sortDataByDate(data), limitConfig)
|
||||||
|
|
||||||
let start = 0
|
|
||||||
const container = document.getElementById('article-container')
|
const container = document.getElementById('article-container')
|
||||||
|
let start = 0
|
||||||
|
|
||||||
const getTimeZoneDate = date => {
|
const renderData = (dataSlice) => {
|
||||||
if (date.length === 10) {
|
const content = dataSlice.map(item => {
|
||||||
date = date + ' 00:00:00'
|
const formattedDate = formatToTimeZone(item.date)
|
||||||
}
|
const tags = item.tags && item.tags.map(tag => `<span class="shuoshuo-tag">${tag}</span>`).join('') || ''
|
||||||
|
const commentButton = item.key && !{commentsJsLoad}
|
||||||
|
? `<div class="shuoshuo-comment-btn" onclick="addCommentToShuoshuo(event)">
|
||||||
|
<i class="fa-solid fa-comments"></i>
|
||||||
|
</div>`
|
||||||
|
: ''
|
||||||
|
const commentContainer = item.key
|
||||||
|
? `<div class="shuoshuo-comment no-comment" data-key="${item.key}"></div>`
|
||||||
|
: ''
|
||||||
|
|
||||||
const visitorTimeZone = '#{config.timezone}' || Intl.DateTimeFormat().resolvedOptions().timeZone
|
return `
|
||||||
const options = {
|
<div class="shuoshuo-item">
|
||||||
timeZone: visitorTimeZone,
|
<div class="shuoshuo-item-header">
|
||||||
year: 'numeric',
|
<div class="shuoshuo-avatar">
|
||||||
month: '2-digit',
|
<img class="no-lightbox" src="${item.avatar || '!{url_for(theme.avatar.img)}'}">
|
||||||
day: '2-digit',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
second: '2-digit',
|
|
||||||
hour12: false
|
|
||||||
}
|
|
||||||
|
|
||||||
const formattedDate = new Intl.DateTimeFormat('en-GB', options).format(new Date(date))
|
|
||||||
|
|
||||||
const [day, month, year, hour, minute, second] = formattedDate.match(/\d+/g)
|
|
||||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const addData = data => {
|
|
||||||
const cLength = data.length
|
|
||||||
const end = start + 10 > cLength ? cLength : start + 10
|
|
||||||
let result = ''
|
|
||||||
data.slice(start, end).forEach((item) => {
|
|
||||||
const getDate = getTimeZoneDate(item.date)
|
|
||||||
result += `
|
|
||||||
<div class="shuoshuo-item">
|
|
||||||
<div class="shuoshuo-item-header">
|
|
||||||
<div class="shuoshuo-avatar">
|
|
||||||
<img class="no-lightbox" src="${item.avatar || '!{url_for(theme.avatar.img)}'}">
|
|
||||||
</div>
|
|
||||||
<div class="shuoshuo-info">
|
|
||||||
<div class="shuoshuo-author">${item.author || '!{config.author}'}</div>
|
|
||||||
<time class="shuoshuo-date" title="${getDate}">${btf.diffDate(getDate, true)}</time>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="shuoshuo-content">
|
|
||||||
${item.content}
|
|
||||||
</div>
|
|
||||||
<div class="shuoshuo-footer">
|
|
||||||
${item.tags && item.tags.length ? `
|
|
||||||
<div class="shuoshuo-footer">
|
|
||||||
<div class="shuoshuo-tags">
|
|
||||||
${item.tags.map(tag => `<span class="shuoshuo-tag">${tag}</span>`).join('')}
|
|
||||||
</div>
|
|
||||||
</div>` : ''}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
`
|
<div class="shuoshuo-info">
|
||||||
})
|
<div class="shuoshuo-author">${item.author || '!{config.author}'}</div>
|
||||||
|
<time class="shuoshuo-date" title="${formattedDate}">
|
||||||
|
${btf.diffDate(formattedDate, true)}
|
||||||
|
</time>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="shuoshuo-content">${item.content}</div>
|
||||||
|
<div class="shuoshuo-footer ${tags ? 'flex-between' : 'flex-end'}">
|
||||||
|
${tags ? `<div class="shuoshuo-tags">${tags}</div>` : ''}
|
||||||
|
${commentButton}
|
||||||
|
</div>
|
||||||
|
${commentContainer}
|
||||||
|
</div>`
|
||||||
|
}).join('')
|
||||||
|
|
||||||
start = end
|
container.insertAdjacentHTML('beforeend', content)
|
||||||
container.insertAdjacentHTML('beforeend', result)
|
|
||||||
|
|
||||||
if (start >= cLength) {
|
|
||||||
observer.disconnect()
|
|
||||||
} else {
|
|
||||||
setTimeout(() => observer.observe(container.lastElementChild), 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
window.lazyLoadInstance.update()
|
window.lazyLoadInstance.update()
|
||||||
btf.loadLightbox(document.querySelectorAll('#article-container img:not(.no-lightbox)'))
|
btf.loadLightbox(document.querySelectorAll('#article-container img:not(.no-lightbox)'))
|
||||||
}
|
}
|
||||||
|
|
||||||
addData(shuoshuo)
|
const handleIntersection = (entries) => {
|
||||||
|
if (!entries[0].isIntersecting) return
|
||||||
|
observer.unobserve(entries[0].target)
|
||||||
|
|
||||||
const observer = new IntersectionObserver((entries) => {
|
const slice = data.slice(start, start + 10)
|
||||||
if (entries[0].isIntersecting) {
|
renderData(slice)
|
||||||
observer.unobserve(entries[0].target)
|
start += 10
|
||||||
addData(shuoshuo)
|
|
||||||
|
if (start < data.length) {
|
||||||
|
setTimeout(() => observer.observe(container.lastElementChild), 100)
|
||||||
|
} else {
|
||||||
|
observer.disconnect()
|
||||||
}
|
}
|
||||||
}, {
|
};
|
||||||
|
|
||||||
|
const observer = new IntersectionObserver(handleIntersection, {
|
||||||
root: null,
|
root: null,
|
||||||
rootMargin: '0px',
|
rootMargin: '0px',
|
||||||
threshold: 1.0
|
threshold: 1.0
|
||||||
})
|
})
|
||||||
|
|
||||||
if (container.lastElementChild) {
|
renderData(data.slice(start, 10))
|
||||||
observer.observe(container.lastElementChild)
|
start += 10
|
||||||
}
|
|
||||||
} catch (e) {
|
if (container.lastElementChild) observer.observe(container.lastElementChild)
|
||||||
console.error(e)
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
window.pjax ? loadShuoshuo() : window.addEventListener('load', loadShuoshuo)
|
window.pjax ? loadShuoshuo() : window.addEventListener('load', loadShuoshuo)
|
||||||
})()
|
})()
|
||||||
else
|
else
|
||||||
if site.data.shuoshuo
|
if site.data.shuoshuo
|
||||||
each i in site.data.shuoshuo
|
each i in shuoshuoFN(site.data.shuoshuo, page)
|
||||||
.shuoshuo-item
|
.shuoshuo-item
|
||||||
.shuoshuo-item-header
|
.shuoshuo-item-header
|
||||||
.shuoshuo-avatar
|
.shuoshuo-avatar
|
||||||
img.no-lightbox(src=i.avatar || url_for(theme.avatar.img))
|
img.no-lightbox(src=i.avatar || url_for(theme.avatar.img))
|
||||||
.shuoshuo-info
|
.shuoshuo-info
|
||||||
.shuoshuo-author=i.author || config.author
|
.shuoshuo-author=i.author || config.author
|
||||||
- const getDate = getTimeZoneDate(i.date)
|
time.shuoshuo-date(title=i.date)=i.date
|
||||||
time.shuoshuo-date(title=getDate)=date(getDate)
|
|
||||||
.shuoshuo-content
|
.shuoshuo-content
|
||||||
!=markdown(i.content)
|
!=markdown(i.content)
|
||||||
.shuoshuo-footer
|
.shuoshuo-footer(class=i.tags && i.tags.length ? 'flex-between' : 'flex-end')
|
||||||
if i.tags
|
if i.tags
|
||||||
.shuoshuo-tags
|
.shuoshuo-tags
|
||||||
each tag in i.tags
|
each tag in i.tags
|
||||||
span.shuoshuo-tag=tag
|
span.shuoshuo-tag=tag
|
||||||
|
if i.key && commentsJsLoad
|
||||||
|
.shuoshuo-comment-btn(onclick='addCommentToShuoshuo(event)')
|
||||||
|
i.fa-solid.fa-comments
|
||||||
|
if i.key && commentsJsLoad
|
||||||
|
.shuoshuo-comment.no-comment(data-key=i.key)
|
||||||
52
layout/includes/third-party/comments/artalk.pug
vendored
52
layout/includes/third-party/comments/artalk.pug
vendored
@@ -4,14 +4,27 @@
|
|||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
let artalkItem = null
|
let artalkItem = null
|
||||||
const initArtalk = () => {
|
const option = !{JSON.stringify(option)}
|
||||||
artalkItem = Artalk.init(Object.assign({
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
el: '#artalk-wrap',
|
|
||||||
|
const destroyArtalk = () => {
|
||||||
|
if (artalkItem) {
|
||||||
|
artalkItem.destroy()
|
||||||
|
artalkItem = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const artalkChangeMode = theme => artalkItem && artalkItem.setDarkMode(theme === 'dark')
|
||||||
|
|
||||||
|
const initArtalk = (el = document, pageKey = location.pathname) => {
|
||||||
|
artalkItem = Artalk.init({
|
||||||
|
el: el.querySelector('#artalk-wrap'),
|
||||||
server: '!{server}',
|
server: '!{server}',
|
||||||
site: '!{site}',
|
site: '!{site}',
|
||||||
pageKey: location.pathname,
|
|
||||||
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
|
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
|
||||||
},!{JSON.stringify(option)}))
|
...option,
|
||||||
|
pageKey: isShuoshuo ? pageKey : (option && option.pageKey) || pageKey
|
||||||
|
})
|
||||||
|
|
||||||
if (GLOBAL_CONFIG.lightbox === 'null') return
|
if (GLOBAL_CONFIG.lightbox === 'null') return
|
||||||
artalkItem.on('list-loaded', () => {
|
artalkItem.on('list-loaded', () => {
|
||||||
@@ -21,31 +34,36 @@ script.
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const destroyArtalk = () => {
|
if (isShuoshuo) {
|
||||||
artalkItem.destroy()
|
window.shuoshuoComment.destroyArtalk = () => {
|
||||||
|
destroyArtalk()
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btf.addGlobalFn('pjaxSendOnce', destroyArtalk, 'destroyArtalk')
|
btf.addGlobalFn('pjaxSendOnce', destroyArtalk, 'destroyArtalk')
|
||||||
|
btf.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadArtalk = async () => {
|
const loadArtalk = async (el, pageKey) => {
|
||||||
if (typeof Artalk === 'object') initArtalk()
|
if (typeof Artalk === 'object') initArtalk(el, pageKey)
|
||||||
else {
|
else {
|
||||||
await btf.getCSS('!{theme.asset.artalk_css}')
|
await btf.getCSS('!{theme.asset.artalk_css}')
|
||||||
await btf.getScript('!{theme.asset.artalk_js}')
|
await btf.getScript('!{theme.asset.artalk_js}')
|
||||||
initArtalk()
|
initArtalk(el, pageKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const artalkChangeMode = theme => {
|
if (isShuoshuo) {
|
||||||
const artalkWrap = document.getElementById('artalk-wrap')
|
'!{use[0]}' === 'Artalk'
|
||||||
if (!(artalkWrap && artalkWrap.children.length)) return
|
? window.shuoshuoComment = { loadComment: loadArtalk }
|
||||||
const isDark = theme === 'dark'
|
: window.loadOtherComment = loadArtalk
|
||||||
artalkItem.setDarkMode(isDark)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
btf.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
|
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Artalk' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Artalk' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
|
if (!{lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
|
||||||
else setTimeout(loadArtalk, 100)
|
else setTimeout(loadArtalk, 100)
|
||||||
|
|||||||
41
layout/includes/third-party/comments/disqus.pug
vendored
41
layout/includes/third-party/comments/disqus.pug
vendored
@@ -4,29 +4,43 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const disqus_config = function () {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
this.page.url = '!{ page.permalink }'
|
|
||||||
this.page.identifier = '!{ url_for(page.path) }'
|
|
||||||
this.page.title = '!{ disqusPageTitle }'
|
|
||||||
}
|
|
||||||
|
|
||||||
const disqusReset = () => {
|
const disqusReset = conf => {
|
||||||
window.DISQUS && window.DISQUS.reset({
|
window.DISQUS && window.DISQUS.reset({
|
||||||
reload: true,
|
reload: true,
|
||||||
config: disqus_config
|
config: conf
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
btf.addGlobalFn('themeChange', disqusReset, 'disqus')
|
const loadDisqus = (el, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyDisqus = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadDisqus = () =>{
|
window.disqus_identifier = isShuoshuo ? path : '!{ url_for(page.path) }'
|
||||||
if (window.DISQUS) disqusReset()
|
window.disqus_url = isShuoshuo ? location.origin + path : '!{ page.permalink }'
|
||||||
|
|
||||||
|
const disqus_config = function () {
|
||||||
|
this.page.url = disqus_url
|
||||||
|
this.page.identifier = disqus_identifier
|
||||||
|
this.page.title = '!{ disqusPageTitle }'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.DISQUS) disqusReset(disqus_config)
|
||||||
else {
|
else {
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script')
|
||||||
script.src = 'https://!{shortname}.disqus.com/embed.js'
|
script.src = 'https://!{shortname}.disqus.com/embed.js'
|
||||||
script.setAttribute('data-timestamp', +new Date())
|
script.setAttribute('data-timestamp', +new Date())
|
||||||
document.head.appendChild(script)
|
document.head.appendChild(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btf.addGlobalFn('themeChange', () => disqusReset(disqus_config), 'disqus')
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCount = async() => {
|
const getCount = async() => {
|
||||||
@@ -47,6 +61,13 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Disqus'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadDisqus }
|
||||||
|
: window.loadOtherComment = loadDisqus
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Disqus' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Disqus' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
|
if (!{lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,36 +1,52 @@
|
|||||||
- let disqusjsPageTitle = page.title.replace(/'/ig,"\\'")
|
- let disqusjsPageTitle = page.title && page.title.replace(/'/ig,"\\'")
|
||||||
- const { shortname:dqShortname, apikey:dqApikey, option:dqOption } = theme.disqusjs
|
- const { shortname:dqShortname, apikey:dqApikey, option:dqOption } = theme.disqusjs
|
||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const initDisqusjs = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
const dqOption = !{JSON.stringify(dqOption)}
|
||||||
|
|
||||||
|
const destroyDisqusjs = () => {
|
||||||
|
disqusjs.destroy()
|
||||||
window.disqusjs = null
|
window.disqusjs = null
|
||||||
disqusjs = new DisqusJS(Object.assign({
|
}
|
||||||
|
|
||||||
|
const themeChange = (el, path) => {
|
||||||
|
destroyDisqusjs()
|
||||||
|
initDisqusjs(el, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
const initDisqusjs = (el = document, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyDisqusjs = () => {
|
||||||
|
destroyDisqusjs()
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disqusjs = new DisqusJS({
|
||||||
shortname: '!{dqShortname}',
|
shortname: '!{dqShortname}',
|
||||||
identifier: '!{ url_for(page.path) }',
|
|
||||||
url: '!{ page.permalink }',
|
|
||||||
title: '!{ disqusjsPageTitle }',
|
title: '!{ disqusjsPageTitle }',
|
||||||
apikey: '!{dqApikey}',
|
apikey: '!{dqApikey}',
|
||||||
},!{JSON.stringify(dqOption)}))
|
...dqOption,
|
||||||
|
identifier: isShuoshuo ? path : (dqOption && dqOption.identifier) || '!{ url_for(page.path) }',
|
||||||
|
url: isShuoshuo ? location.origin + path : (dqOption && dqOption.url) || '!{ page.permalink }'
|
||||||
|
})
|
||||||
|
|
||||||
disqusjs.render(document.getElementById('disqusjs-wrap'))
|
disqusjs.render(el.querySelector('#disqusjs-wrap'))
|
||||||
|
|
||||||
|
btf.addGlobalFn('themeChange', () => themeChange(el, path), 'disqusjs')
|
||||||
}
|
}
|
||||||
|
|
||||||
const themeChange = () => {
|
const loadDisqusjs = async(el, path) => {
|
||||||
const ele = document.getElementById('disqus_thread')
|
if (window.disqusJsLoad) initDisqusjs(el, path)
|
||||||
if(!ele) return
|
|
||||||
disqusjs.destroy()
|
|
||||||
initDisqusjs()
|
|
||||||
}
|
|
||||||
|
|
||||||
btf.addGlobalFn('themeChange', themeChange, 'disqusjs')
|
|
||||||
|
|
||||||
const loadDisqusjs = async() => {
|
|
||||||
if (window.disqusJsLoad) initDisqusjs()
|
|
||||||
else {
|
else {
|
||||||
await btf.getCSS('!{url_for(theme.asset.disqusjs_css)}')
|
await btf.getCSS('!{url_for(theme.asset.disqusjs_css)}')
|
||||||
await btf.getScript('!{url_for(theme.asset.disqusjs)}')
|
await btf.getScript('!{url_for(theme.asset.disqusjs)}')
|
||||||
initDisqusjs()
|
initDisqusjs(el, path)
|
||||||
window.disqusJsLoad = true
|
window.disqusJsLoad = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,6 +68,13 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{theme.comments.use[0]}' === 'Disqusjs'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadDisqusjs }
|
||||||
|
: window.loadOtherComment = loadDisqusjs
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqusjs-wrap'), loadDisqusjs)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqusjs-wrap'), loadDisqusjs)
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -3,17 +3,28 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(()=>{
|
(()=>{
|
||||||
const loadFBComment = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
|
||||||
|
const loadFBComment = (el = document, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyFB = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
|
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
|
||||||
|
|
||||||
const themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
const themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||||
const $fbComment = document.getElementsByClassName('fb-comments')[0]
|
const $fbComment = el.getElementsByClassName('fb-comments')[0]
|
||||||
$fbComment.setAttribute('data-colorscheme',themeNow)
|
$fbComment.setAttribute('data-colorscheme',themeNow)
|
||||||
$fbComment.setAttribute('data-href', '!{urlNoIndex(page.permalink)}')
|
$fbComment.setAttribute('data-href', isShuoshuo ? '!{urlNoIndex(page.permalink)}' + '#' + path : '!{urlNoIndex(page.permalink)}')
|
||||||
|
|
||||||
if (typeof FB === 'object') {
|
if (typeof FB === 'object') {
|
||||||
FB.XFBML.parse(document.getElementsByClassName('post-meta-commentcount')[0])
|
FB.XFBML.parse(document.getElementsByClassName('post-meta-commentcount')[0])
|
||||||
FB.XFBML.parse(document.getElementById('post-comment'))
|
FB.XFBML.parse(el.querySelector('#post-comment'))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let ele = document.createElement('script')
|
let ele = document.createElement('script')
|
||||||
@@ -36,6 +47,13 @@ script.
|
|||||||
|
|
||||||
btf.addGlobalFn('themeChange', fbModeChange, 'facebook_comments')
|
btf.addGlobalFn('themeChange', fbModeChange, 'facebook_comments')
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{theme.comments.use[0]}' === 'Facebook Comments'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadFBComment }
|
||||||
|
: window.loadOtherComment = loadFBComment
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
|
||||||
else loadFBComment()
|
else loadFBComment()
|
||||||
|
|||||||
54
layout/includes/third-party/comments/giscus.pug
vendored
54
layout/includes/third-party/comments/giscus.pug
vendored
@@ -4,27 +4,50 @@
|
|||||||
- const giscusOriginUrl = new URL(giscusUrl).origin
|
- const giscusOriginUrl = new URL(giscusUrl).origin
|
||||||
|
|
||||||
script.
|
script.
|
||||||
(()=>{
|
(() => {
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
const option = !{JSON.stringify(option)}
|
||||||
|
|
||||||
const getGiscusTheme = theme => theme === 'dark' ? '!{dark_theme}' : '!{light_theme}'
|
const getGiscusTheme = theme => theme === 'dark' ? '!{dark_theme}' : '!{light_theme}'
|
||||||
|
|
||||||
const loadGiscus = () => {
|
const createScriptElement = config => {
|
||||||
const config = Object.assign({
|
const ele = document.createElement('script')
|
||||||
|
Object.entries(config).forEach(([key, value]) => {
|
||||||
|
ele.setAttribute(key, value)
|
||||||
|
})
|
||||||
|
return ele
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadGiscus = (el = document, key) => {
|
||||||
|
const mappingConfig = isShuoshuo
|
||||||
|
? { 'data-mapping': 'specific', 'data-term': key }
|
||||||
|
: { 'data-mapping': (option && option['data-mapping']) || 'pathname' }
|
||||||
|
|
||||||
|
const giscusConfig = {
|
||||||
src: '!{giscusUrl}',
|
src: '!{giscusUrl}',
|
||||||
'data-repo': '!{repo}',
|
'data-repo': '!{repo}',
|
||||||
'data-repo-id': '!{repo_id}',
|
'data-repo-id': '!{repo_id}',
|
||||||
'data-category-id': '!{category_id}',
|
'data-category-id': '!{category_id}',
|
||||||
'data-mapping': 'pathname',
|
|
||||||
'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
|
'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
|
||||||
'data-reactions-enabled': '1',
|
'data-reactions-enabled': '1',
|
||||||
crossorigin: 'anonymous',
|
crossorigin: 'anonymous',
|
||||||
async: true
|
async: true,
|
||||||
},!{JSON.stringify(option)})
|
...option,
|
||||||
|
...mappingConfig
|
||||||
const ele = document.createElement('script')
|
}
|
||||||
for (let key in config) {
|
|
||||||
ele.setAttribute(key, config[key])
|
const scriptElement = createScriptElement(giscusConfig)
|
||||||
|
|
||||||
|
el.querySelector('#giscus-wrap').appendChild(scriptElement)
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyGiscus = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
document.getElementById('giscus-wrap').appendChild(ele)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeGiscusTheme = theme => {
|
const changeGiscusTheme = theme => {
|
||||||
@@ -43,10 +66,17 @@ script.
|
|||||||
|
|
||||||
btf.addGlobalFn('themeChange', changeGiscusTheme, 'giscus')
|
btf.addGlobalFn('themeChange', changeGiscusTheme, 'giscus')
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Giscus'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadGiscus }
|
||||||
|
: window.loadOtherComment = loadGiscus
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Giscus' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Giscus' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('giscus-wrap'), loadGiscus)
|
if (!{lazyload}) btf.loadComment(document.getElementById('giscus-wrap'), loadGiscus)
|
||||||
else loadGiscus()
|
else loadGiscus()
|
||||||
} else {
|
} else {
|
||||||
window.loadOtherComment= loadGiscus
|
window.loadOtherComment = loadGiscus
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
64
layout/includes/third-party/comments/gitalk.pug
vendored
64
layout/includes/third-party/comments/gitalk.pug
vendored
@@ -2,28 +2,8 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const initGitalk = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
const gitalk = new Gitalk(Object.assign({
|
const option = !{JSON.stringify(option)}
|
||||||
clientID: '!{client_id}',
|
|
||||||
clientSecret: '!{client_secret}',
|
|
||||||
repo: '!{repo}',
|
|
||||||
owner: '!{owner}',
|
|
||||||
admin: ['!{admin}'],
|
|
||||||
id: '!{md5(page.path)}',
|
|
||||||
updateCountCallback: commentCount
|
|
||||||
},!{JSON.stringify(option)}))
|
|
||||||
|
|
||||||
gitalk.render('gitalk-container')
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadGitalk = async() => {
|
|
||||||
if (typeof Gitalk === 'function') initGitalk()
|
|
||||||
else {
|
|
||||||
await btf.getCSS('!{url_for(theme.asset.gitalk_css)}')
|
|
||||||
await btf.getScript('!{url_for(theme.asset.gitalk)}')
|
|
||||||
initGitalk()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const commentCount = n => {
|
const commentCount = n => {
|
||||||
const isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
|
const isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
|
||||||
@@ -32,6 +12,46 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initGitalk = (el, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyGitalk = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const gitalk = new Gitalk({
|
||||||
|
clientID: '!{client_id}',
|
||||||
|
clientSecret: '!{client_secret}',
|
||||||
|
repo: '!{repo}',
|
||||||
|
owner: '!{owner}',
|
||||||
|
admin: ['!{admin}'],
|
||||||
|
updateCountCallback: commentCount,
|
||||||
|
...option,
|
||||||
|
id: isShuoshuo ? path : (option && option.id) || '!{md5(page.path)}'
|
||||||
|
})
|
||||||
|
|
||||||
|
gitalk.render('gitalk-container')
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadGitalk = async(el, path) => {
|
||||||
|
if (typeof Gitalk === 'function') initGitalk(el, path)
|
||||||
|
else {
|
||||||
|
await btf.getCSS('!{url_for(theme.asset.gitalk_css)}')
|
||||||
|
await btf.getScript('!{url_for(theme.asset.gitalk)}')
|
||||||
|
initGitalk(el, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{theme.comments.use[0]}' === 'Gitalk'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadGitalk }
|
||||||
|
: window.loadOtherComment = loadGitalk
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
|
||||||
else loadGitalk()
|
else loadGitalk()
|
||||||
|
|||||||
26
layout/includes/third-party/comments/livere.pug
vendored
26
layout/includes/third-party/comments/livere.pug
vendored
@@ -1,8 +1,23 @@
|
|||||||
- const { use, lazyload } = theme.comments
|
- const { use, lazyload } = theme.comments
|
||||||
|
|
||||||
script.
|
script.
|
||||||
(()=>{
|
(() => {
|
||||||
const loadLivere = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
|
||||||
|
const loadLivere = (el, path) => {
|
||||||
|
window.livereOptions = {
|
||||||
|
refer: path || location.pathname
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyLivere = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof LivereTower === 'object') window.LivereTower.init()
|
if (typeof LivereTower === 'object') window.LivereTower.init()
|
||||||
else {
|
else {
|
||||||
(function(d, s) {
|
(function(d, s) {
|
||||||
@@ -16,6 +31,13 @@ script.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Livere'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadLivere }
|
||||||
|
: window.loadOtherComment = loadLivere
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Livere' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Livere' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('lv-container'), loadLivere)
|
if (!{lazyload}) btf.loadComment(document.getElementById('lv-container'), loadLivere)
|
||||||
else loadLivere()
|
else loadLivere()
|
||||||
|
|||||||
118
layout/includes/third-party/comments/remark42.pug
vendored
118
layout/includes/third-party/comments/remark42.pug
vendored
@@ -1,68 +1,78 @@
|
|||||||
- const { host, siteId, option } = theme.remark42
|
- const { host, siteId, option } = theme.remark42
|
||||||
|
|
||||||
script.
|
script.
|
||||||
var remark_config = Object.assign({
|
(() => {
|
||||||
host: '!{host}',
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
site_id: '!{siteId}',
|
const option = !{JSON.stringify(option)}
|
||||||
components: ['embed'],
|
|
||||||
theme: document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
|
||||||
},!{JSON.stringify(option)})
|
|
||||||
|
|
||||||
function addRemark42(){
|
const loadScript = src => {
|
||||||
for (let i = 0; i < remark_config.components.length; i++) {
|
const script = document.createElement('script')
|
||||||
const s = document.createElement('script')
|
script.src = src
|
||||||
s.src = remark_config.host + '/web/' + remark_config.components[i] + '.js'
|
script.defer = true
|
||||||
s.defer = true
|
document.head.appendChild(script)
|
||||||
document.head.appendChild(s)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function initRemark42() {
|
const addRemark42 = () => loadScript('!{host}/web/embed.js')
|
||||||
if (window.REMARK42) {
|
|
||||||
if (this.remark42Instance) {
|
const getCount = () => document.querySelector('.remark42__counter') && loadScript('!{host}/web/count.js')
|
||||||
this.remark42Instance.destroy()
|
|
||||||
|
const destroyRemark42 = () => window.remark42Instance && window.remark42Instance.destroy()
|
||||||
|
|
||||||
|
const initRemark42 = remark_config => {
|
||||||
|
if (window.REMARK42) {
|
||||||
|
destroyRemark42()
|
||||||
|
window.remark42Instance = window.REMARK42.createInstance({
|
||||||
|
...remark_config
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadRemark42 = (el, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyRemark42 = () => {
|
||||||
|
destroyRemark42()
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remark42Instance = window.REMARK42.createInstance({
|
window.remark_config = {
|
||||||
...remark_config
|
host: '!{host}',
|
||||||
})
|
site_id: '!{siteId}',
|
||||||
}
|
theme: document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light',
|
||||||
}
|
...option,
|
||||||
|
url: isShuoshuo ? window.location.origin + path : (option && option.url) || window.location.origin + window.location.pathname
|
||||||
|
}
|
||||||
|
|
||||||
function getCount () {
|
if (window.REMARK42) {
|
||||||
const ele = document.querySelector('.remark42__counter')
|
initRemark42(remark_config)
|
||||||
if (ele) {
|
|
||||||
const s = document.createElement('script')
|
|
||||||
s.src = remark_config.host + '/web/counter.js'
|
|
||||||
s.defer = true
|
|
||||||
document.head.appendChild(s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadRemark42 () {
|
|
||||||
if (window.REMARK42) {
|
|
||||||
this.initRemark42()
|
|
||||||
getCount()
|
|
||||||
} else {
|
|
||||||
addRemark42()
|
|
||||||
window.addEventListener('REMARK42::ready', () => {
|
|
||||||
this.initRemark42()
|
|
||||||
getCount()
|
getCount()
|
||||||
})
|
} else {
|
||||||
|
addRemark42()
|
||||||
|
window.addEventListener('REMARK42::ready', () => {
|
||||||
|
initRemark42(remark_config)
|
||||||
|
getCount()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function remarkChangeMode (theme) {
|
const remarkChangeMode = theme => window.REMARK42 && window.REMARK42.changeTheme(theme)
|
||||||
if (!window.REMARK42) return
|
|
||||||
window.REMARK42.changeTheme(theme)
|
|
||||||
}
|
|
||||||
|
|
||||||
btf.addGlobalFn('themeChange', remarkChangeMode, 'remark42')
|
btf.addGlobalFn('themeChange', remarkChangeMode, 'remark42')
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
if (isShuoshuo) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
'!{theme.comments.use[0]}' === 'Remark42'
|
||||||
else loadRemark42()
|
? window.shuoshuoComment = { loadComment: loadRemark42 }
|
||||||
} else {
|
: window.loadOtherComment = loadRemark42
|
||||||
function loadOtherComment () {
|
return
|
||||||
loadRemark42()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
||||||
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
||||||
|
else loadRemark42()
|
||||||
|
} else {
|
||||||
|
window.loadOtherComment = loadRemark42
|
||||||
|
}
|
||||||
|
})()
|
||||||
35
layout/includes/third-party/comments/twikoo.pug
vendored
35
layout/includes/third-party/comments/twikoo.pug
vendored
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
const option = !{JSON.stringify(option)}
|
||||||
|
|
||||||
const getCount = () => {
|
const getCount = () => {
|
||||||
const countELement = document.getElementById('twikoo-count')
|
const countELement = document.getElementById('twikoo-count')
|
||||||
if(!countELement) return
|
if(!countELement) return
|
||||||
@@ -18,22 +21,38 @@ script.
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const init = () => {
|
const init = (el = document, path = location.pathname) => {
|
||||||
twikoo.init(Object.assign({
|
twikoo.init({
|
||||||
el: '#twikoo-wrap',
|
el: el.querySelector('#twikoo-wrap'),
|
||||||
envId: '!{envId}',
|
envId: '!{envId}',
|
||||||
region: '!{region}',
|
region: '!{region}',
|
||||||
onCommentLoaded: () => {
|
onCommentLoaded: () => {
|
||||||
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
||||||
}
|
},
|
||||||
}, !{JSON.stringify(option)}))
|
...option,
|
||||||
|
path: isShuoshuo ? path : (option && option.path) || path
|
||||||
|
})
|
||||||
|
|
||||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||||
|
|
||||||
|
isShuoshuo && (window.shuoshuoComment.destroyTwikoo = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadTwikoo = () => {
|
const loadTwikoo = (el, path) => {
|
||||||
if (typeof twikoo === 'object') setTimeout(init,0)
|
if (typeof twikoo === 'object') setTimeout(() => init(el, path), 0)
|
||||||
else btf.getScript('!{url_for(theme.asset.twikoo)}').then(init)
|
else btf.getScript('!{url_for(theme.asset.twikoo)}').then(() => init(el, path))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Twikoo'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadTwikoo }
|
||||||
|
: window.loadOtherComment = loadTwikoo
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
||||||
|
|||||||
@@ -5,24 +5,33 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
const option = !{JSON.stringify(option)}
|
||||||
const getUtterancesTheme = theme => theme === 'dark' ? '#{dark_theme}' : '#{light_theme}'
|
const getUtterancesTheme = theme => theme === 'dark' ? '#{dark_theme}' : '#{light_theme}'
|
||||||
|
|
||||||
const loadUtterances = () => {
|
const loadUtterances = (el = document, key) => {
|
||||||
const config = Object.assign({
|
if (isShuoshuo) {
|
||||||
id: 'utterances_comment',
|
window.shuoshuoComment.destroyUtterances = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = {
|
||||||
src: '!{utterancesUrl}',
|
src: '!{utterancesUrl}',
|
||||||
repo: '!{repo}',
|
repo: '!{repo}',
|
||||||
'issue-term': '!{issue_term}',
|
|
||||||
theme: getUtterancesTheme(document.documentElement.getAttribute('data-theme')),
|
theme: getUtterancesTheme(document.documentElement.getAttribute('data-theme')),
|
||||||
crossorigin: 'anonymous',
|
crossorigin: 'anonymous',
|
||||||
async: true
|
async: true,
|
||||||
},!{JSON.stringify(option)})
|
...option,
|
||||||
|
'issue-term': isShuoshuo ? key : (option && option['issue-term']) || '!{issue_term}'
|
||||||
|
}
|
||||||
|
|
||||||
const ele = document.createElement('script')
|
const ele = document.createElement('script')
|
||||||
for (let key in config) {
|
Object.entries(config).forEach(([key, value]) => ele.setAttribute(key, value))
|
||||||
ele.setAttribute(key, config[key])
|
el.querySelector('#utterances-wrap').appendChild(ele)
|
||||||
}
|
|
||||||
document.getElementById('utterances-wrap').appendChild(ele)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeUtterancesTheme = theme => {
|
const changeUtterancesTheme = theme => {
|
||||||
@@ -38,6 +47,13 @@ script.
|
|||||||
|
|
||||||
btf.addGlobalFn('themeChange', changeUtterancesTheme, 'utterances')
|
btf.addGlobalFn('themeChange', changeUtterancesTheme, 'utterances')
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Utterances'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadUtterances }
|
||||||
|
: window.loadOtherComment = loadUtterances
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Utterances' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Utterances' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
|
if (!{lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
|
||||||
else loadUtterances()
|
else loadUtterances()
|
||||||
|
|||||||
42
layout/includes/third-party/comments/valine.pug
vendored
42
layout/includes/third-party/comments/valine.pug
vendored
@@ -7,27 +7,50 @@ if site.data.valine
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const initValine = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
const valine = new Valine(Object.assign({
|
const option = !{JSON.stringify(option)}
|
||||||
|
|
||||||
|
const initValine = (el, path) => {
|
||||||
|
if (isShuoshuo) {
|
||||||
|
window.shuoshuoComment.destroyValine = () => {
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const valineConfig = {
|
||||||
el: '#vcomment',
|
el: '#vcomment',
|
||||||
appId: '#{appId}',
|
appId: '#{appId}',
|
||||||
appKey: '#{appKey}',
|
appKey: '#{appKey}',
|
||||||
avatar: '#{avatar}',
|
avatar: '#{avatar}',
|
||||||
serverURLs: '#{serverURLs}',
|
serverURLs: '#{serverURLs}',
|
||||||
emojiMaps: !{emojiMaps},
|
emojiMaps: !{emojiMaps},
|
||||||
path: window.location.pathname,
|
visitor: #{visitor},
|
||||||
visitor: #{visitor}
|
...option,
|
||||||
}, !{JSON.stringify(option)}))
|
path: isShuoshuo ? path : (option && option.path) || window.location.pathname
|
||||||
|
}
|
||||||
|
|
||||||
|
new Valine(valineConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadValine = async () => {
|
const loadValine = async (el, path) => {
|
||||||
if (typeof Valine === 'function') initValine()
|
if (typeof Valine === 'function') {
|
||||||
else {
|
initValine(el, path)
|
||||||
|
} else {
|
||||||
await btf.getScript('!{url_for(theme.asset.valine)}')
|
await btf.getScript('!{url_for(theme.asset.valine)}')
|
||||||
initValine()
|
initValine(el, path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Valine'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadValine }
|
||||||
|
: window.loadOtherComment = loadValine
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Valine' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Valine' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('vcomment'),loadValine)
|
if (!{lazyload}) btf.loadComment(document.getElementById('vcomment'),loadValine)
|
||||||
else setTimeout(loadValine, 0)
|
else setTimeout(loadValine, 0)
|
||||||
@@ -35,4 +58,3 @@ script.
|
|||||||
window.loadOtherComment = loadValine
|
window.loadOtherComment = loadValine
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|||||||
40
layout/includes/third-party/comments/waline.pug
vendored
40
layout/includes/third-party/comments/waline.pug
vendored
@@ -4,37 +4,53 @@
|
|||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
let initFn = window.walineFn || null
|
let initFn = window.walineFn || null
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.isShuoshuo
|
||||||
|
const option = !{JSON.stringify(option)}
|
||||||
|
|
||||||
const initWaline = (Fn) => {
|
const destroyWaline = ele => ele.destroy()
|
||||||
const waline = Fn(Object.assign({
|
|
||||||
el: '#waline-wrap',
|
const initWaline = (Fn, el = document, path = window.location.pathname) => {
|
||||||
|
const waline = Fn({
|
||||||
|
el: el.querySelector('#waline-wrap'),
|
||||||
serverURL: '!{serverURL}',
|
serverURL: '!{serverURL}',
|
||||||
pageview: !{lazyload ? false : pageview},
|
pageview: !{lazyload ? false : pageview},
|
||||||
dark: 'html[data-theme="dark"]',
|
dark: 'html[data-theme="dark"]',
|
||||||
path: window.location.pathname,
|
|
||||||
comment: !{lazyload ? false : count},
|
comment: !{lazyload ? false : count},
|
||||||
}, !{JSON.stringify(option)}))
|
...option,
|
||||||
|
path: isShuoshuo ? path : (option && option.path) || path
|
||||||
|
})
|
||||||
|
|
||||||
const destroyWaline = () => {
|
if (isShuoshuo) {
|
||||||
waline.destroy()
|
window.shuoshuoComment.destroyWaline = () => {
|
||||||
|
destroyWaline(waline)
|
||||||
|
if (el.children.length) {
|
||||||
|
el.innerHTML = ''
|
||||||
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btf.addGlobalFn('pjaxSendOnce', destroyWaline, 'destroyWaline')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadWaline = () => {
|
const loadWaline = (el, path) => {
|
||||||
if (initFn) initWaline(initFn)
|
if (initFn) initWaline(initFn, el, path)
|
||||||
else {
|
else {
|
||||||
btf.getCSS('!{url_for(theme.asset.waline_css)}')
|
btf.getCSS('!{url_for(theme.asset.waline_css)}')
|
||||||
.then(() => import('!{url_for(theme.asset.waline_js)}'))
|
.then(() => import('!{url_for(theme.asset.waline_js)}'))
|
||||||
.then(({ init }) => {
|
.then(({ init }) => {
|
||||||
initFn = init || Waline.init
|
initFn = init || Waline.init
|
||||||
initWaline(initFn)
|
initWaline(initFn, el, path)
|
||||||
window.walineFn = initFn
|
window.walineFn = initFn
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isShuoshuo) {
|
||||||
|
'!{use[0]}' === 'Waline'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadWaline }
|
||||||
|
: window.loadOtherComment = loadWaline
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
||||||
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
||||||
else setTimeout(loadWaline, 0)
|
else setTimeout(loadWaline, 0)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- const { host, siteId } = theme.remark42
|
- const { host, siteId } = theme.remark42
|
||||||
|
!= partial("includes/third-party/newest-comments/common.pug", {}, { cache: true })
|
||||||
|
|
||||||
script.
|
script.
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
|
|||||||
16
plugins.yml
16
plugins.yml
@@ -1,7 +1,7 @@
|
|||||||
abcjs_basic_js:
|
abcjs_basic_js:
|
||||||
name: abcjs
|
name: abcjs
|
||||||
file: dist/abcjs-basic-min.js
|
file: dist/abcjs-basic-min.js
|
||||||
version: 6.4.3
|
version: 6.4.4
|
||||||
activate_power_mode:
|
activate_power_mode:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: dist/activate-power-mode.min.js
|
file: dist/activate-power-mode.min.js
|
||||||
@@ -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.9.1
|
version: 5.12.0
|
||||||
aplayer_css:
|
aplayer_css:
|
||||||
name: aplayer
|
name: aplayer
|
||||||
file: dist/APlayer.min.css
|
file: dist/APlayer.min.css
|
||||||
@@ -44,8 +44,8 @@ canvas_ribbon:
|
|||||||
version: 1.1.4
|
version: 1.1.4
|
||||||
chartjs:
|
chartjs:
|
||||||
name: chart.js
|
name: chart.js
|
||||||
file: dist/chart.umd.min.js
|
file: dist/chart.umd.js
|
||||||
version: 4.4.5
|
version: 4.4.6
|
||||||
clickShowText:
|
clickShowText:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: dist/click-show-text.min.js
|
file: dist/click-show-text.min.js
|
||||||
@@ -66,12 +66,12 @@ 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.6.2
|
version: 3.6.3
|
||||||
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.6.2
|
version: 3.6.3
|
||||||
egjs_infinitegrid:
|
egjs_infinitegrid:
|
||||||
name: '@egjs/infinitegrid'
|
name: '@egjs/infinitegrid'
|
||||||
other_name: egjs-infinitegrid
|
other_name: egjs-infinitegrid
|
||||||
@@ -111,7 +111,7 @@ instantpage:
|
|||||||
instantsearch:
|
instantsearch:
|
||||||
name: instantsearch.js
|
name: instantsearch.js
|
||||||
file: dist/instantsearch.production.min.js
|
file: dist/instantsearch.production.min.js
|
||||||
version: 4.75.1
|
version: 4.75.3
|
||||||
katex:
|
katex:
|
||||||
name: katex
|
name: katex
|
||||||
file: dist/katex.min.css
|
file: dist/katex.min.css
|
||||||
@@ -137,7 +137,7 @@ medium_zoom:
|
|||||||
mermaid:
|
mermaid:
|
||||||
name: mermaid
|
name: mermaid
|
||||||
file: dist/mermaid.min.js
|
file: dist/mermaid.min.js
|
||||||
version: 11.3.0
|
version: 11.4.0
|
||||||
meting_js:
|
meting_js:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: metingjs/dist/Meting.min.js
|
file: metingjs/dist/Meting.min.js
|
||||||
|
|||||||
@@ -7,11 +7,18 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
let { use } = themeConfig.comments
|
let { use } = themeConfig.comments
|
||||||
if (!use) return
|
if (!use) return
|
||||||
|
|
||||||
// 確保 use 是一個陣列
|
// Make sure use is an array
|
||||||
use = Array.isArray(use) ? use : use.split(',')
|
use = Array.isArray(use) ? use : use.split(',')
|
||||||
|
|
||||||
// 將每個項目轉換為小寫並將首字母大寫
|
// Capitalize the first letter of each comment name
|
||||||
themeConfig.comments.use = use.map(item =>
|
use = use.map(item =>
|
||||||
item.trim().toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase())
|
item.trim().toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Disqus and Disqusjs conflict, only keep the first one
|
||||||
|
if (use.includes('Disqus') && use.includes('Disqusjs')) {
|
||||||
|
use = [use[0]]
|
||||||
|
}
|
||||||
|
|
||||||
|
themeConfig.comments.use = use
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ hexo.extend.helper.register('inject_head_js', function () {
|
|||||||
if (!${pjax.enable} && key.startsWith('pjax')) return
|
if (!${pjax.enable} && key.startsWith('pjax')) return
|
||||||
const globalFn = parent.globalFn || {}
|
const globalFn = parent.globalFn || {}
|
||||||
globalFn[key] = globalFn[key] || {}
|
globalFn[key] = globalFn[key] || {}
|
||||||
if (name && globalFn[key][name]) return
|
|
||||||
globalFn[key][name || Object.keys(globalFn[key]).length] = fn
|
globalFn[key][name || Object.keys(globalFn[key]).length] = fn
|
||||||
parent.globalFn = globalFn
|
parent.globalFn = globalFn
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,6 @@ const { prettyUrls } = require('hexo-util')
|
|||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const moment = require('moment-timezone')
|
const moment = require('moment-timezone')
|
||||||
|
|
||||||
hexo.extend.helper.register('getTimeZoneDate', date => {
|
|
||||||
// This is a hack method, because hexo treats time as UTC time
|
|
||||||
// so you need to manually convert the time zone
|
|
||||||
const utcDate = moment.utc(date).format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
return moment.tz(utcDate, hexo.config.timezone).format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
})
|
|
||||||
|
|
||||||
hexo.extend.helper.register('truncate', truncateContent)
|
hexo.extend.helper.register('truncate', truncateContent)
|
||||||
|
|
||||||
hexo.extend.helper.register('postDesc', data => {
|
hexo.extend.helper.register('postDesc', data => {
|
||||||
@@ -103,3 +96,31 @@ hexo.extend.helper.register('getBgPath', path => {
|
|||||||
return `background: ${path};`
|
return `background: ${path};`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hexo.extend.helper.register('shuoshuoFN', (data, page) => {
|
||||||
|
const { limit } = page
|
||||||
|
let finalResult = ''
|
||||||
|
|
||||||
|
// Check if limit.value is a valid date
|
||||||
|
const isValidDate = (date) => !isNaN(Date.parse(date))
|
||||||
|
|
||||||
|
// order by date
|
||||||
|
data.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))
|
||||||
|
|
||||||
|
// Apply number limit or time limit conditionally
|
||||||
|
if (limit && limit.type === 'num' && limit.value > 0) {
|
||||||
|
finalResult = data.slice(0, limit.value)
|
||||||
|
} else if (limit && limit.type === 'date' && isValidDate(limit.value)) {
|
||||||
|
const limitDate = Date.parse(limit.value)
|
||||||
|
finalResult = data.filter(item => Date.parse(item.date) >= limitDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a hack method, because hexo treats time as UTC time
|
||||||
|
// so you need to manually convert the time zone
|
||||||
|
finalResult.forEach(item => {
|
||||||
|
const utcDate = moment.utc(item.date).format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
item.date = moment.tz(utcDate, hexo.config.timezone).format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
})
|
||||||
|
|
||||||
|
return finalResult
|
||||||
|
})
|
||||||
|
|||||||
@@ -37,18 +37,42 @@
|
|||||||
& > *:last-child
|
& > *:last-child
|
||||||
margin-bottom: 0
|
margin-bottom: 0
|
||||||
|
|
||||||
.shuoshuo-tag
|
.shuoshuo-footer
|
||||||
display: inline-block
|
display: flex
|
||||||
margin-right: 8px
|
align-items: center
|
||||||
padding: 0 8px
|
|
||||||
width: fit-content
|
|
||||||
border: 1px solid $light-blue
|
|
||||||
border-radius: 12px
|
|
||||||
color: $light-blue
|
|
||||||
font-size: .85em
|
|
||||||
cursor: default
|
|
||||||
transition: all .2s ease-in-out
|
|
||||||
|
|
||||||
&:hover
|
&.flex-between
|
||||||
background: $light-blue
|
justify-content: space-between
|
||||||
color: var(--white)
|
|
||||||
|
&.flex-end
|
||||||
|
justify-content: flex-end
|
||||||
|
|
||||||
|
.shuoshuo-tag
|
||||||
|
display: inline-block
|
||||||
|
margin-right: 8px
|
||||||
|
padding: 0 8px
|
||||||
|
width: fit-content
|
||||||
|
border: 1px solid $light-blue
|
||||||
|
border-radius: 12px
|
||||||
|
color: $light-blue
|
||||||
|
font-size: .85em
|
||||||
|
cursor: default
|
||||||
|
transition: all .2s ease-in-out
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
background: $light-blue
|
||||||
|
color: var(--white)
|
||||||
|
|
||||||
|
.shuoshuo-comment-btn
|
||||||
|
padding: 2px
|
||||||
|
color: #90a4ae
|
||||||
|
cursor: pointer
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
color: $light-blue
|
||||||
|
|
||||||
|
.shuoshuo-comment
|
||||||
|
padding-top: 10px
|
||||||
|
|
||||||
|
&.no-comment
|
||||||
|
display: none
|
||||||
|
|||||||
@@ -806,22 +806,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
btf.addEventListenerPjax(cardCategory, 'click', handleToggleBtn, true)
|
btf.addEventListenerPjax(cardCategory, 'click', handleToggleBtn, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const switchComments = () => {
|
|
||||||
const switchBtn = document.getElementById('switch-btn')
|
|
||||||
if (!switchBtn) return
|
|
||||||
|
|
||||||
let switchDone = false
|
|
||||||
const postComment = document.getElementById('post-comment')
|
|
||||||
const handleSwitchBtn = () => {
|
|
||||||
postComment.classList.toggle('move')
|
|
||||||
if (!switchDone && typeof loadOtherComment === 'function') {
|
|
||||||
switchDone = true
|
|
||||||
loadOtherComment()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
btf.addEventListenerPjax(switchBtn, 'click', handleSwitchBtn)
|
|
||||||
}
|
|
||||||
|
|
||||||
const addPostOutdateNotice = () => {
|
const addPostOutdateNotice = () => {
|
||||||
const { limitDay, messagePrev, messageNext, position } = GLOBAL_CONFIG.noticeOutdate
|
const { limitDay, messagePrev, messageNext, position } = GLOBAL_CONFIG.noticeOutdate
|
||||||
const diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)
|
const diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)
|
||||||
@@ -924,7 +908,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
scrollFn()
|
scrollFn()
|
||||||
|
|
||||||
forPostFn()
|
forPostFn()
|
||||||
switchComments()
|
!GLOBAL_CONFIG_SITE.isShuoshuo && btf.switchComments(document)
|
||||||
openMobileMenu()
|
openMobileMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,22 @@
|
|||||||
Object.keys(keyObj).forEach(i => keyObj[i]())
|
Object.keys(keyObj).forEach(i => keyObj[i]())
|
||||||
|
|
||||||
delete globalFn[key]
|
delete globalFn[key]
|
||||||
|
},
|
||||||
|
|
||||||
|
switchComments: (el = document, path) => {
|
||||||
|
const switchBtn = el.querySelector('#switch-btn')
|
||||||
|
if (!switchBtn) return
|
||||||
|
|
||||||
|
let switchDone = false
|
||||||
|
const postComment = el.querySelector('#post-comment')
|
||||||
|
const handleSwitchBtn = () => {
|
||||||
|
postComment.classList.toggle('move')
|
||||||
|
if (!switchDone && typeof loadOtherComment === 'function') {
|
||||||
|
switchDone = true
|
||||||
|
loadOtherComment(el, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
btf.addEventListenerPjax(switchBtn, 'click', handleSwitchBtn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user