mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
Compare commits
56 Commits
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.DS_Store
|
||||||
|
.DS_Store
|
||||||
@@ -86,7 +86,7 @@ npm i hexo-theme-butterfly
|
|||||||
- [x] Share (Sharejs/Addtoany)
|
- [x] Share (Sharejs/Addtoany)
|
||||||
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
|
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
|
||||||
- [x] Multiple Comment System Support
|
- [x] Multiple Comment System Support
|
||||||
- [x] Online Chats (Chatra/Tidio/Daovoice/Crisp)
|
- [x] Online Chats (Chatra/Tidio/Crisp)
|
||||||
- [x] Web analytics
|
- [x] Web analytics
|
||||||
- [x] Google AdSense
|
- [x] Google AdSense
|
||||||
- [x] Webmaster Verification
|
- [x] Webmaster Verification
|
||||||
@@ -98,9 +98,10 @@ npm i hexo-theme-butterfly
|
|||||||
- [x] Busuanzi visitor counter
|
- [x] Busuanzi visitor counter
|
||||||
- [x] Medium Zoom/Fancybox
|
- [x] Medium Zoom/Fancybox
|
||||||
- [x] Mermaid
|
- [x] Mermaid
|
||||||
|
- [x] Chart.js
|
||||||
- [x] Justified Gallery
|
- [x] Justified Gallery
|
||||||
- [x] Lazyload images
|
- [x] Lazyload images
|
||||||
- [x] Instantpage/Pangu/Snackbar notification toast/PWA......
|
- [x] Instantpage/Snackbar notification toast/PWA......
|
||||||
|
|
||||||
## ✨ Contributors
|
## ✨ Contributors
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ theme: butterfly
|
|||||||
- [x] 多種分享系統(Sharejs/Addtoany)
|
- [x] 多種分享系統(Sharejs/Addtoany)
|
||||||
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
|
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
|
||||||
- [x] 支持雙評論部署
|
- [x] 支持雙評論部署
|
||||||
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Crisp)
|
- [x] 多種在線聊天(Chatra/Tidio/Crisp)
|
||||||
- [x] 多種分析系統
|
- [x] 多種分析系統
|
||||||
- [x] 谷歌廣告/手動廣告位置
|
- [x] 谷歌廣告/手動廣告位置
|
||||||
- [x] 各種站長驗證
|
- [x] 各種站長驗證
|
||||||
@@ -98,9 +98,10 @@ theme: butterfly
|
|||||||
- [x] 不蒜子訪問統計
|
- [x] 不蒜子訪問統計
|
||||||
- [x] 兩種大圖模式(Medium Zoom/Fancybox)
|
- [x] 兩種大圖模式(Medium Zoom/Fancybox)
|
||||||
- [x] Mermaid 圖表顯示
|
- [x] Mermaid 圖表顯示
|
||||||
|
- [x] Chart.js 圖表顯示
|
||||||
- [x] 照片牆
|
- [x] 照片牆
|
||||||
- [x] 圖片懶加載
|
- [x] 圖片懶加載
|
||||||
- [x] Instantpage/Pangu/Snackbar彈窗/PWA......
|
- [x] Instantpage/Snackbar彈窗/PWA......
|
||||||
|
|
||||||
## ✨ 貢獻者
|
## ✨ 貢獻者
|
||||||
|
|
||||||
|
|||||||
42
_config.yml
42
_config.yml
@@ -158,7 +158,7 @@ subtitle:
|
|||||||
# Choose: false/1/2/3
|
# Choose: false/1/2/3
|
||||||
# false - disable the function
|
# false - disable the function
|
||||||
# 1 - hitokoto.cn
|
# 1 - hitokoto.cn
|
||||||
# 2 - yijuzhan.com
|
# 2 - https://api.aa1.cn/doc/yiyan.html
|
||||||
# 3 - jinrishici.com
|
# 3 - jinrishici.com
|
||||||
source: false
|
source: false
|
||||||
# If you close the typewriter effect, the subtitle will only show the first line of sub
|
# If you close the typewriter effect, the subtitle will only show the first line of sub
|
||||||
@@ -602,7 +602,7 @@ facebook_comments:
|
|||||||
pageSize: 10
|
pageSize: 10
|
||||||
# Choose: social / time / reverse_time
|
# Choose: social / time / reverse_time
|
||||||
order_by: social
|
order_by: social
|
||||||
lang: zh_TW
|
lang: en_US
|
||||||
|
|
||||||
# Twikoo
|
# Twikoo
|
||||||
# https://github.com/imaegoo/twikoo
|
# https://github.com/imaegoo/twikoo
|
||||||
@@ -645,7 +645,7 @@ artalk:
|
|||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
chat:
|
chat:
|
||||||
# Choose: chatra/tidio/daovoice/crisp
|
# Choose: chatra/tidio/crisp
|
||||||
# Leave it empty if you don't need chat
|
# Leave it empty if you don't need chat
|
||||||
use:
|
use:
|
||||||
# Chat Button [recommend]
|
# Chat Button [recommend]
|
||||||
@@ -662,10 +662,6 @@ chatra:
|
|||||||
tidio:
|
tidio:
|
||||||
public_key:
|
public_key:
|
||||||
|
|
||||||
# http://dashboard.daovoice.io/app
|
|
||||||
daovoice:
|
|
||||||
app_id:
|
|
||||||
|
|
||||||
# https://crisp.chat/en/
|
# https://crisp.chat/en/
|
||||||
crisp:
|
crisp:
|
||||||
website_id:
|
website_id:
|
||||||
@@ -924,6 +920,25 @@ mermaid:
|
|||||||
light: default
|
light: default
|
||||||
dark: dark
|
dark: dark
|
||||||
|
|
||||||
|
# chartjs
|
||||||
|
# see https://www.chartjs.org/docs/latest/
|
||||||
|
chartjs:
|
||||||
|
enable: false
|
||||||
|
# Do not modify unless you understand how they work.
|
||||||
|
# The default settings are only used when the MD syntax is not specified.
|
||||||
|
# General font color for the chart
|
||||||
|
fontColor:
|
||||||
|
light: 'rgba(0, 0, 0, 0.8)'
|
||||||
|
dark: 'rgba(255, 255, 255, 0.8)'
|
||||||
|
# General border color for the chart
|
||||||
|
borderColor:
|
||||||
|
light: 'rgba(0, 0, 0, 0.1)'
|
||||||
|
dark: 'rgba(255, 255, 255, 0.2)'
|
||||||
|
# Background color for scale labels on radar and polar area charts
|
||||||
|
scale_ticks_backdropColor:
|
||||||
|
light: 'transparent'
|
||||||
|
dark: 'transparent'
|
||||||
|
|
||||||
# Note - Bootstrap Callout
|
# Note - Bootstrap Callout
|
||||||
note:
|
note:
|
||||||
# Note tag style values:
|
# Note tag style values:
|
||||||
@@ -968,13 +983,6 @@ snackbar:
|
|||||||
# https://instant.page/
|
# https://instant.page/
|
||||||
instantpage: false
|
instantpage: false
|
||||||
|
|
||||||
# Pangu - Insert a space between Chinese character and English character
|
|
||||||
# https://github.com/vinta/pangu.js
|
|
||||||
pangu:
|
|
||||||
enable: false
|
|
||||||
# Specify the field to use pangu (site or post)
|
|
||||||
field: site
|
|
||||||
|
|
||||||
# Lazyload
|
# Lazyload
|
||||||
# https://github.com/verlok/vanilla-lazyload
|
# https://github.com/verlok/vanilla-lazyload
|
||||||
lazyload:
|
lazyload:
|
||||||
@@ -1008,6 +1016,10 @@ Open_Graph_meta:
|
|||||||
# fb_admins:
|
# fb_admins:
|
||||||
# fb_app_id:
|
# fb_app_id:
|
||||||
|
|
||||||
|
# Structured Data
|
||||||
|
# https://developers.google.com/search/docs/guides/intro-structured-data
|
||||||
|
structured_data: true
|
||||||
|
|
||||||
# Add the vendor prefixes to ensure compatibility
|
# Add the vendor prefixes to ensure compatibility
|
||||||
css_prefix: true
|
css_prefix: true
|
||||||
|
|
||||||
@@ -1050,6 +1062,7 @@ CDN:
|
|||||||
# canvas_fluttering_ribbon:
|
# canvas_fluttering_ribbon:
|
||||||
# canvas_nest:
|
# canvas_nest:
|
||||||
# canvas_ribbon:
|
# canvas_ribbon:
|
||||||
|
# chartjs:
|
||||||
# click_heart:
|
# click_heart:
|
||||||
# clickShowText:
|
# clickShowText:
|
||||||
# disqusjs:
|
# disqusjs:
|
||||||
@@ -1076,7 +1089,6 @@ CDN:
|
|||||||
# medium_zoom:
|
# medium_zoom:
|
||||||
# mermaid:
|
# mermaid:
|
||||||
# meting_js:
|
# meting_js:
|
||||||
# pangu:
|
|
||||||
# prismjs_autoloader:
|
# prismjs_autoloader:
|
||||||
# prismjs_js:
|
# prismjs_js:
|
||||||
# prismjs_lineNumber_js:
|
# prismjs_lineNumber_js:
|
||||||
|
|||||||
@@ -11,15 +11,12 @@ div
|
|||||||
if theme.instantpage
|
if theme.instantpage
|
||||||
script(src=url_for(theme.asset.instantpage), type='module')
|
script(src=url_for(theme.asset.instantpage), type='module')
|
||||||
|
|
||||||
if theme.lazyload.enable
|
if theme.lazyload.enable && !theme.lazyload.native
|
||||||
script(src=url_for(theme.asset.lazyload))
|
script(src=url_for(theme.asset.lazyload))
|
||||||
|
|
||||||
if theme.snackbar.enable
|
if theme.snackbar.enable
|
||||||
script(src=url_for(theme.asset.snackbar))
|
script(src=url_for(theme.asset.snackbar))
|
||||||
|
|
||||||
if theme.pangu.enable
|
|
||||||
!= partial("includes/third-party/pangu.pug", {}, { cache: true })
|
|
||||||
|
|
||||||
.js-pjax
|
.js-pjax
|
||||||
if needLoadCountJs
|
if needLoadCountJs
|
||||||
!= partial("includes/third-party/card-post-count/index", {}, { cache: true })
|
!= partial("includes/third-party/card-post-count/index", {}, { cache: true })
|
||||||
@@ -36,7 +33,7 @@ div
|
|||||||
!= partial("includes/third-party/prismjs", {}, { cache: true })
|
!= partial("includes/third-party/prismjs", {}, { cache: true })
|
||||||
|
|
||||||
if theme.aside.enable && theme.aside.card_newest_comments.enable
|
if theme.aside.enable && theme.aside.card_newest_comments.enable
|
||||||
if theme.pjax.enable || (!is_post() && page.aside !== false)
|
if theme.pjax.enable || (globalPageType !== 'post' && page.aside !== false)
|
||||||
!= partial("includes/third-party/newest-comments/index", {}, { cache: true })
|
!= partial("includes/third-party/newest-comments/index", {}, { cache: true })
|
||||||
|
|
||||||
!= fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
|
!= fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
else
|
else
|
||||||
!= `©${currentYear} By ${config.author}`
|
!= `©${currentYear} By ${config.author}`
|
||||||
if theme.footer.copyright
|
if theme.footer.copyright
|
||||||
|
- const v = getVersion()
|
||||||
.framework-info
|
.framework-info
|
||||||
span= _p('footer.framework') + ' '
|
span= _p('footer.framework') + ' '
|
||||||
a(href='https://hexo.io')= 'Hexo'
|
a(href='https://hexo.io')= `Hexo ${v.hexo}`
|
||||||
span.footer-separator |
|
span.footer-separator |
|
||||||
span= _p('footer.theme') + ' '
|
span= _p('footer.theme') + ' '
|
||||||
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
|
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= `Butterfly ${v.theme}`
|
||||||
if theme.footer.custom_text
|
if theme.footer.custom_text
|
||||||
.footer_custom_text!= theme.footer.custom_text
|
.footer_custom_text!= theme.footer.custom_text
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
- var pageTitle
|
- var pageTitle
|
||||||
- is_archive() ? page.title = findArchivesTitle(page, theme.menu, date) : ''
|
- globalPageType === 'archive' ? page.title = findArchivesTitle(page, theme.menu, date) : ''
|
||||||
- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
|
case globalPageType
|
||||||
- else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
|
when 'tag'
|
||||||
- else if (is_current('/404.html', [strict])) pageTitle = _p('error404')
|
- pageTitle = _p('page.tag') + ': ' + page.tag
|
||||||
- else pageTitle = page.title || config.title || ''
|
when 'category'
|
||||||
|
- pageTitle = _p('page.category') + ': ' + page.category
|
||||||
|
when '404'
|
||||||
|
- pageTitle = _p('error404')
|
||||||
|
default
|
||||||
|
- pageTitle = page.title || config.title || ''
|
||||||
|
|
||||||
|
|
||||||
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
|
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
|
||||||
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
|
- var tabTitle = globalPageType === 'home' || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
|
||||||
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
||||||
- var pageCopyright = config.copyright || config.author
|
- var pageCopyright = config.copyright || config.author
|
||||||
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
|
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
|
||||||
@@ -25,6 +31,9 @@ meta(name="theme-color" content=themeColor)
|
|||||||
//- Open_Graph
|
//- Open_Graph
|
||||||
include ./head/Open_Graph.pug
|
include ./head/Open_Graph.pug
|
||||||
|
|
||||||
|
//- Structured Data
|
||||||
|
include ./head/structured_data.pug
|
||||||
|
|
||||||
!=favicon_tag(theme.favicon || config.favicon)
|
!=favicon_tag(theme.favicon || config.favicon)
|
||||||
link(rel="canonical" href=urlNoIndex(null,config.pretty_urls.trailing_index,config.pretty_urls.trailing_html))
|
link(rel="canonical" href=urlNoIndex(null,config.pretty_urls.trailing_index,config.pretty_urls.trailing_html))
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ if theme.Open_Graph_meta.enable
|
|||||||
-
|
-
|
||||||
const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
|
const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
|
||||||
let ogOption = Object.assign({
|
let ogOption = Object.assign({
|
||||||
type: is_post() ? 'article' : 'website',
|
type: globalPageType === 'post' ? 'article' : 'website',
|
||||||
image: coverVal ? full_url_for(coverVal) : '',
|
image: coverVal ? full_url_for(coverVal) : '',
|
||||||
fb_admins: theme.facebook_comments.user_id || '',
|
fb_admins: theme.facebook_comments.user_id || '',
|
||||||
fb_app_id: theme.facebook_comments.app_id || '',
|
fb_app_id: theme.facebook_comments.app_id || '',
|
||||||
|
|||||||
@@ -69,16 +69,6 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let noticeOutdate = 'undefined'
|
|
||||||
if (theme.noticeOutdate && theme.noticeOutdate.enable) {
|
|
||||||
noticeOutdate = JSON.stringify({
|
|
||||||
limitDay: theme.noticeOutdate.limit_day,
|
|
||||||
position: theme.noticeOutdate.position,
|
|
||||||
messagePrev: theme.noticeOutdate.message_prev,
|
|
||||||
messageNext: theme.noticeOutdate.message_next,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let highlight = 'undefined'
|
let highlight = 'undefined'
|
||||||
let syntaxHighlighter = config.syntax_highlighter
|
let syntaxHighlighter = config.syntax_highlighter
|
||||||
let highlightEnable = syntaxHighlighter ? ['highlight.js', 'prismjs'].includes(syntaxHighlighter) : (config.highlight.enable || config.prismjs.enable)
|
let highlightEnable = syntaxHighlighter ? ['highlight.js', 'prismjs'].includes(syntaxHighlighter) : (config.highlight.enable || config.prismjs.enable)
|
||||||
@@ -100,7 +90,6 @@ script.
|
|||||||
algolia: !{algolia},
|
algolia: !{algolia},
|
||||||
localSearch: !{localSearch},
|
localSearch: !{localSearch},
|
||||||
translate: !{translate},
|
translate: !{translate},
|
||||||
noticeOutdate: !{noticeOutdate},
|
|
||||||
highlight: !{highlight},
|
highlight: !{highlight},
|
||||||
copy: {
|
copy: {
|
||||||
success: '!{_p("copy.success")}',
|
success: '!{_p("copy.success")}',
|
||||||
@@ -127,7 +116,7 @@ script.
|
|||||||
buttonText: '!{_p("load_more")}'
|
buttonText: '!{_p("load_more")}'
|
||||||
},
|
},
|
||||||
isPhotoFigcaption: !{theme.photofigcaption},
|
isPhotoFigcaption: !{theme.photofigcaption},
|
||||||
islazyload: !{theme.lazyload.enable},
|
islazyloadPlugin: !{theme.lazyload.enable && !theme.lazyload.native},
|
||||||
isAnchor: !{theme.anchor.auto_update || false},
|
isAnchor: !{theme.anchor.auto_update || false},
|
||||||
percent: {
|
percent: {
|
||||||
toc: !{theme.toc.scroll_percent},
|
toc: !{theme.toc.scroll_percent},
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
var showToc = false
|
var showToc = false
|
||||||
if (theme.aside.enable && page.aside !== false) {
|
if (theme.aside.enable && page.aside !== false) {
|
||||||
let tocEnable = false
|
let tocEnable = false
|
||||||
if (is_post() && theme.toc.post) tocEnable = true
|
if (globalPageType === 'post' && theme.toc.post) tocEnable = true
|
||||||
else if (is_page() && theme.toc.page) tocEnable = true
|
else if (globalPageType === 'page' && theme.toc.page) tocEnable = true
|
||||||
const pageToc = typeof page.toc === 'boolean' ? page.toc : tocEnable
|
const pageToc = typeof page.toc === 'boolean' ? page.toc : tocEnable
|
||||||
showToc = pageToc && (toc(page.content) !== '' || page.encrypt === true)
|
showToc = pageToc && (toc(page.content) !== '' || page.encrypt === true)
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
script#config-diff.
|
script#config-diff.
|
||||||
var GLOBAL_CONFIG_SITE = {
|
var GLOBAL_CONFIG_SITE = {
|
||||||
title: '!{titleVal}',
|
title: '!{titleVal}',
|
||||||
isPost: !{is_post()},
|
|
||||||
isHome: !{is_home()},
|
|
||||||
isHighlightShrink: !{isHighlightShrink},
|
isHighlightShrink: !{isHighlightShrink},
|
||||||
isToc: !{showToc},
|
isToc: !{showToc},
|
||||||
postUpdate: '!{full_date(page.updated)}'
|
pageType: '!{page.type == 'shuoshuo' ? 'shuoshuo' : globalPageType}'
|
||||||
}
|
}
|
||||||
|
|||||||
34
layout/includes/head/structured_data.pug
Normal file
34
layout/includes/head/structured_data.pug
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
if theme.structured_data && page.layout === 'post'
|
||||||
|
-
|
||||||
|
// use json-ld to add structured data
|
||||||
|
|
||||||
|
const title = page.title
|
||||||
|
const url = page.permalink
|
||||||
|
const imageVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
|
||||||
|
const image = imageVal ? full_url_for(imageVal) : ''
|
||||||
|
const datePublished = page.date.toISOString()
|
||||||
|
const dateModified = (page.updated || page.date).toISOString()
|
||||||
|
const author = page.copyright_author || config.author
|
||||||
|
const authorHrefVal = page.copyright_author_href || theme.post_copyright.author_href || site.url;
|
||||||
|
const authorHref = full_url_for(authorHrefVal);
|
||||||
|
|
||||||
|
const jsonLd = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "BlogPosting",
|
||||||
|
"headline": title,
|
||||||
|
"url": url,
|
||||||
|
"image": image,
|
||||||
|
"datePublished": datePublished,
|
||||||
|
"dateModified": dateModified,
|
||||||
|
"author": [{
|
||||||
|
"@type": "Person",
|
||||||
|
"name": author,
|
||||||
|
"url": authorHref
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
jsonLdScript = JSON.stringify(jsonLd, null, 2);
|
||||||
|
-
|
||||||
|
|
||||||
|
script(type="application/ld+json").
|
||||||
|
!{jsonLdScript}
|
||||||
@@ -6,33 +6,32 @@
|
|||||||
var bg_img = ''
|
var bg_img = ''
|
||||||
|
|
||||||
if !theme.disable_top_img && page.top_img !== false
|
if !theme.disable_top_img && page.top_img !== false
|
||||||
if is_post()
|
case globalPageType
|
||||||
|
when 'post'
|
||||||
- top_img = page.top_img || page.cover || theme.default_top_img
|
- top_img = page.top_img || page.cover || theme.default_top_img
|
||||||
else if is_page()
|
when 'page'
|
||||||
- top_img = page.top_img || theme.default_top_img
|
- top_img = page.top_img || theme.default_top_img
|
||||||
else if is_tag()
|
when 'tag'
|
||||||
- top_img = theme.tag_per_img && theme.tag_per_img[page.tag]
|
- top_img = theme.tag_per_img && theme.tag_per_img[page.tag] || returnTopImg(theme.tag_img)
|
||||||
- top_img = top_img || returnTopImg(theme.tag_img)
|
when 'category'
|
||||||
else if is_category()
|
- top_img = theme.category_per_img && theme.category_per_img[page.category] || returnTopImg(theme.category_img)
|
||||||
- top_img = theme.category_per_img && theme.category_per_img[page.category]
|
when 'home'
|
||||||
- top_img = top_img || returnTopImg(theme.category_img)
|
|
||||||
else if is_home()
|
|
||||||
- top_img = returnTopImg(theme.index_img)
|
- top_img = returnTopImg(theme.index_img)
|
||||||
else if is_archive()
|
when 'archive'
|
||||||
- top_img = returnTopImg(theme.archive_img)
|
- top_img = returnTopImg(theme.archive_img)
|
||||||
else
|
default
|
||||||
- top_img = page.top_img || theme.default_top_img
|
- top_img = page.top_img || theme.default_top_img
|
||||||
|
|
||||||
if top_img !== false
|
if top_img !== false
|
||||||
- bg_img = getBgPath(top_img)
|
- bg_img = getBgPath(top_img)
|
||||||
- headerClassName = is_home() ? 'full_page' : is_post() ? 'post-bg' : 'not-home-page'
|
- headerClassName = globalPageType === 'home' ? 'full_page' : globalPageType === 'post' ? 'post-bg' : 'not-home-page'
|
||||||
|
|
||||||
header#page-header(class=`${headerClassName + isFixedClass}` style=bg_img)
|
header#page-header(class=`${headerClassName + isFixedClass}` style=bg_img)
|
||||||
include ./nav.pug
|
include ./nav.pug
|
||||||
if top_img !== false
|
if top_img !== false
|
||||||
if is_post()
|
if globalPageType === 'post'
|
||||||
include ./post-info.pug
|
include ./post-info.pug
|
||||||
else if is_home()
|
else if globalPageType === 'home'
|
||||||
#site-info
|
#site-info
|
||||||
h1#site-title=config.title
|
h1#site-title=config.title
|
||||||
if theme.subtitle.enable
|
if theme.subtitle.enable
|
||||||
@@ -48,6 +47,6 @@ header#page-header(class=`${headerClassName + isFixedClass}` style=bg_img)
|
|||||||
#page-site-info
|
#page-site-info
|
||||||
h1#site-title=page.title || page.tag || page.category
|
h1#site-title=page.title || page.tag || page.category
|
||||||
else
|
else
|
||||||
//- improvement seo
|
//- improve seo
|
||||||
if !is_post()
|
if globalPageType !== 'post'
|
||||||
h1.title-seo=page.title || page.tag || page.category || config.title
|
h1.title-seo=page.title || page.tag || page.category || config.title
|
||||||
@@ -5,7 +5,7 @@ nav#nav
|
|||||||
img.site-icon(src=url_for(theme.nav.logo) alt='Logo')
|
img.site-icon(src=url_for(theme.nav.logo) alt='Logo')
|
||||||
if theme.nav.display_title
|
if theme.nav.display_title
|
||||||
span.site-name=config.title
|
span.site-name=config.title
|
||||||
if is_post()
|
if globalPageType === 'post'
|
||||||
a.nav-page-title(href=url_for('/'))
|
a.nav-page-title(href=url_for('/'))
|
||||||
span.site-name=(page.title || config.title)
|
span.site-name=(page.title || config.title)
|
||||||
#menus
|
#menus
|
||||||
|
|||||||
@@ -60,47 +60,38 @@
|
|||||||
if block
|
if block
|
||||||
block
|
block
|
||||||
|
|
||||||
|
mixin otherPV()
|
||||||
|
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.page_pv
|
||||||
|
+pvBlock('', '', '')
|
||||||
|
span#umamiPV(data-path=url_for(page.path))
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
else if theme.busuanzi.page_pv
|
||||||
|
+pvBlock('', 'post-meta-pv-cv', '')
|
||||||
|
span#busuanzi_value_page_pv
|
||||||
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
- const commentUse = comments.use && comments.use[0]
|
- const commentUse = comments.use && comments.use[0]
|
||||||
if page.comments !== false && commentUse && !comments.lazyload
|
if page.comments !== false && commentUse && !comments.lazyload
|
||||||
case commentUse
|
if commentUse === 'Valine' && theme.valine.visitor
|
||||||
when 'Valine'
|
|
||||||
if theme.valine.visitor
|
|
||||||
+pvBlock(url_for(page.path), 'leancloud_visitors', page.title)
|
+pvBlock(url_for(page.path), 'leancloud_visitors', page.title)
|
||||||
span.leancloud-visitors-count
|
span.leancloud-visitors-count
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Waline'
|
else if commentUse === 'Waline' && theme.waline.pageview
|
||||||
if theme.waline.pageview
|
|
||||||
+pvBlock('', '', '')
|
+pvBlock('', '', '')
|
||||||
span.waline-pageview-count(data-path=url_for(page.path))
|
span.waline-pageview-count(data-path=url_for(page.path))
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Twikoo'
|
else if commentUse === 'Twikoo' && theme.twikoo.visitor
|
||||||
if theme.twikoo.visitor
|
|
||||||
+pvBlock('', '', '')
|
+pvBlock('', '', '')
|
||||||
span#twikoo_visitors
|
span#twikoo_visitors
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
when 'Artalk'
|
else if commentUse === 'Artalk' && theme.artalk.visitor
|
||||||
if theme.artalk.visitor
|
|
||||||
+pvBlock('', '', '')
|
+pvBlock('', '', '')
|
||||||
span#ArtalkPV
|
span#ArtalkPV
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
default
|
|
||||||
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.page_pv
|
|
||||||
+pvBlock('', '', '')
|
|
||||||
span#umamiPV(data-path=url_for(page.path))
|
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
|
||||||
else if theme.busuanzi.page_pv
|
|
||||||
+pvBlock('', 'post-meta-pv-cv', '')
|
|
||||||
span#busuanzi_value_page_pv
|
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
|
||||||
else
|
else
|
||||||
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.page_pv
|
+otherPV()
|
||||||
+pvBlock('', '', '')
|
else
|
||||||
span#umamiPV(data-path=url_for(page.path))
|
+otherPV()
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
|
||||||
else if theme.busuanzi.page_pv
|
|
||||||
+pvBlock('', 'post-meta-pv-cv', '')
|
|
||||||
span#busuanzi_value_page_pv
|
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
|
||||||
|
|
||||||
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
if comments.count && !comments.lazyload && page.comments !== false && comments.use
|
||||||
- var whichCount = comments.use[0]
|
- var whichCount = comments.use[0]
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
- var globalPageType = getPageType(page, is_home)
|
||||||
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
|
||||||
- page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside
|
- page.aside = globalPageType === 'archive' ? theme.aside.display.archive: globalPageType === 'category' ? theme.aside.display.category : globalPageType === 'tag' ? theme.aside.display.tag : page.aside
|
||||||
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
|
||||||
- var pageType = is_post() ? 'post' : 'page'
|
- var pageType = globalPageType === 'post' ? 'post' : 'page'
|
||||||
- pageType = page.type ? pageType + ' type-' + page.type : pageType
|
- pageType = page.type ? pageType + ' type-' + page.type : pageType
|
||||||
|
|
||||||
doctype html
|
doctype html
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ mixin indexPostUI()
|
|||||||
div.post-bg(style=`background: ${post_cover}`)
|
div.post-bg(style=`background: ${post_cover}`)
|
||||||
.recent-post-info(class=no_cover)
|
.recent-post-info(class=no_cover)
|
||||||
a.article-title(href=url_for(link) title=title)
|
a.article-title(href=url_for(link) title=title)
|
||||||
if is_home() && (article.top || article.sticky > 0)
|
if globalPageType === 'home' && (article.top || article.sticky > 0)
|
||||||
i.fas.fa-thumbtack.sticky
|
i.fas.fa-thumbtack.sticky
|
||||||
= title
|
= title
|
||||||
.article-meta-wrap
|
.article-meta-wrap
|
||||||
@@ -105,15 +105,9 @@ mixin indexPostUI()
|
|||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
//- Display the article introduction on homepage
|
//- Display the article introduction on homepage
|
||||||
case theme.index_post_content.method
|
- const content = postDesc(article)
|
||||||
when false
|
if content
|
||||||
- break
|
.content!=content
|
||||||
when 1
|
|
||||||
.content!= article.description
|
|
||||||
when 2
|
|
||||||
.content!= article.description || truncate(article.content, theme.index_post_content.length)
|
|
||||||
default
|
|
||||||
.content!= truncate(article.content, theme.index_post_content.length)
|
|
||||||
|
|
||||||
if theme.ad && theme.ad.index
|
if theme.ad && theme.ad.index
|
||||||
if (index + 1) % 3 === 0
|
if (index + 1) % 3 === 0
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#article-container
|
#article-container.container
|
||||||
!= page.content
|
!= page.content
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#article-container
|
#article-container.container
|
||||||
.flink
|
.flink
|
||||||
- let { content, random, flink_url } = page
|
- let { content, random, flink_url } = page
|
||||||
- let pageContent = content
|
- let pageContent = content
|
||||||
|
|||||||
@@ -6,98 +6,183 @@
|
|||||||
//- - 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.closest('.container').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 addData = data => {
|
const renderData = (dataSlice) => {
|
||||||
const cLength = data.length
|
const content = dataSlice.map(item => {
|
||||||
const end = start + 10 > cLength ? cLength : start + 10
|
const formattedDate = formatToTimeZone(item.date)
|
||||||
let result = ''
|
const tags = item.tags && item.tags.map(tag => `<span class="shuoshuo-tag">${tag}</span>`).join('') || ''
|
||||||
data.slice(start, end).forEach((item) => {
|
const commentButton = item.key && !{commentsJsLoad}
|
||||||
result += `
|
? `<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>`
|
||||||
|
: ''
|
||||||
|
|
||||||
|
return `
|
||||||
<div class="shuoshuo-item">
|
<div class="shuoshuo-item">
|
||||||
|
<div class="container">
|
||||||
<div class="shuoshuo-item-header">
|
<div class="shuoshuo-item-header">
|
||||||
<div class="shuoshuo-avatar">
|
<div class="shuoshuo-avatar">
|
||||||
<img class="no-lightbox" src="${item.avatar || '!{url_for(theme.avatar.img)}'}">
|
<img class="no-lightbox" src="${item.avatar || '!{url_for(theme.avatar.img)}'}">
|
||||||
</div>
|
</div>
|
||||||
<div class="shuoshuo-info">
|
<div class="shuoshuo-info">
|
||||||
<div class="shuoshuo-author">${item.author || '!{config.author}'}</div>
|
<div class="shuoshuo-author">${item.author || '!{config.author}'}</div>
|
||||||
<div class="shuoshuo-date">${btf.diffDate(item.date, true)}</div>
|
<time class="shuoshuo-date" title="${formattedDate}">
|
||||||
|
${btf.diffDate(formattedDate, true)}
|
||||||
|
</time>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="shuoshuo-content">
|
<div class="shuoshuo-content">${item.content}</div>
|
||||||
${item.content}
|
<div class="shuoshuo-footer ${tags ? 'flex-between' : 'flex-end'}">
|
||||||
</div>
|
${tags ? `<div class="shuoshuo-tags">${tags}</div>` : ''}
|
||||||
<div class="shuoshuo-footer">
|
${commentButton}
|
||||||
<div class="shuoshuo-tags">
|
|
||||||
${item.tags.map(tag => `<span class="shuoshuo-tag">${tag}</span>`).join('')}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</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
|
||||||
const observer = new IntersectionObserver((entries) => {
|
|
||||||
if (entries[0].isIntersecting) {
|
|
||||||
observer.unobserve(entries[0].target)
|
observer.unobserve(entries[0].target)
|
||||||
addData(shuoshuo)
|
|
||||||
|
const slice = data.slice(start, start + 10)
|
||||||
|
renderData(slice)
|
||||||
|
start += 10
|
||||||
|
|
||||||
|
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
|
||||||
|
.container
|
||||||
.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
|
||||||
.shuoshuo-date=relative_date(i.date)
|
time.shuoshuo-date(title=i.date)=i.date
|
||||||
.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
|
||||||
.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)
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
.tag-cloud-list.is-center
|
.tag-cloud-list.text-center
|
||||||
!=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 1.5, limit: 0, unit: 'em'})
|
!=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 1.5, limit: 0, unit: 'em'})
|
||||||
@@ -6,34 +6,32 @@
|
|||||||
escape: false
|
escape: false
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_post()
|
if globalPageType === 'post'
|
||||||
- let prev = theme.post_pagination === 1 ? page.prev : page.next
|
- let paginationOrder = theme.post_pagination === 1 ? { prev: page.prev, next: page.next } : { prev: page.next, next: page.prev }
|
||||||
- let next = theme.post_pagination === 1 ? page.next : page.prev
|
|
||||||
nav#pagination.pagination-post
|
|
||||||
if(prev)
|
|
||||||
- var hasPageNext = next ? 'pull-left' : 'pull-full'
|
|
||||||
a.prev-post(class=hasPageNext href=url_for(prev.path) title=prev.title)
|
|
||||||
if prev.cover_type === 'img'
|
|
||||||
img.cover(src=url_for(prev.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post')
|
|
||||||
else
|
|
||||||
.cover(style=`background: ${prev.cover || 'var(--default-bg-color)'}`)
|
|
||||||
.pagination-info
|
|
||||||
.label=_p('pagination.prev')
|
|
||||||
.prev_info=prev.title
|
|
||||||
|
|
||||||
if(next)
|
nav#pagination.pagination-post
|
||||||
- var hasPagePrev = prev ? 'pull-right' : 'pull-full'
|
each direction, key in paginationOrder
|
||||||
a.next-post(class=hasPagePrev href=url_for(next.path) title=next.title)
|
if direction
|
||||||
if next.cover_type === 'img'
|
- const getPostDesc = direction.postDesc || postDesc(direction)
|
||||||
img.cover(src=url_for(next.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
|
- let className = key === 'prev' ? (paginationOrder.next ? '' : 'full-width') : (paginationOrder.prev ? '' : 'full-width')
|
||||||
|
- className = getPostDesc ? className : className + ' no-desc'
|
||||||
|
|
||||||
|
a.pagination-related(class=className href=url_for(direction.path) title=direction.title)
|
||||||
|
if direction.cover_type === 'img'
|
||||||
|
img.cover(src=url_for(direction.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt=`cover of ${key === 'prev' ? 'previous' : 'next'} post`)
|
||||||
else
|
else
|
||||||
.cover(style=`background: ${next.cover || 'var(--default-bg-color)'}`)
|
.cover(style=`background: ${direction.cover || 'var(--default-bg-color)'}`)
|
||||||
.pagination-info
|
|
||||||
.label=_p('pagination.next')
|
.info(class=key === 'prev' ? '' : 'text-right')
|
||||||
.next_info=next.title
|
.info-1
|
||||||
|
.info-item-1=_p(`pagination.${key}`)
|
||||||
|
.info-item-2!=direction.title
|
||||||
|
if getPostDesc
|
||||||
|
.info-2
|
||||||
|
.info-item-1!=getPostDesc
|
||||||
else
|
else
|
||||||
nav#pagination
|
nav#pagination
|
||||||
.pagination
|
.pagination
|
||||||
if is_home()
|
if globalPageType === 'home'
|
||||||
- options.format = 'page/%d/#content-inner'
|
- options.format = 'page/%d/#content-inner'
|
||||||
!=paginator(options)
|
!=paginator(options)
|
||||||
8
layout/includes/post/outdate-notice.pug
Normal file
8
layout/includes/post/outdate-notice.pug
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
- const { limit_day, message_prev, message_next, position} = theme.noticeOutdate
|
||||||
|
- const notice_data = { limitDay: limit_day, messagePrev: message_prev, messageNext: message_next, postUpdate: full_date(page.updated)}
|
||||||
|
if position === 'top'
|
||||||
|
#post-outdate-notice(data=notice_data hidden)
|
||||||
|
!=page.content
|
||||||
|
else
|
||||||
|
!=page.content
|
||||||
|
#post-outdate-notice(data=notice_data hidden)
|
||||||
@@ -3,7 +3,7 @@ mixin rightsideItem(array)
|
|||||||
each item in array
|
each item in array
|
||||||
case item
|
case item
|
||||||
when 'readmode'
|
when 'readmode'
|
||||||
if is_post() && readmode
|
if globalPageType === 'post' && readmode
|
||||||
button#readmode(type="button" title=_p('rightside.readmode_title'))
|
button#readmode(type="button" title=_p('rightside.readmode_title'))
|
||||||
i.fas.fa-book-open
|
i.fas.fa-book-open
|
||||||
when 'translate'
|
when 'translate'
|
||||||
@@ -23,7 +23,7 @@ mixin rightsideItem(array)
|
|||||||
i.fas.fa-list-ul
|
i.fas.fa-list-ul
|
||||||
when 'chat'
|
when 'chat'
|
||||||
if chat.rightside_button && chat.use
|
if chat.rightside_button && chat.use
|
||||||
button#chat-btn(type="button" title=_p("rightside.chat"))
|
button#chat-btn(type="button" title=_p("rightside.chat") style="display:none")
|
||||||
i.fas.fa-message
|
i.fas.fa-message
|
||||||
when 'comment'
|
when 'comment'
|
||||||
if commentsJsLoad
|
if commentsJsLoad
|
||||||
@@ -45,7 +45,7 @@ mixin rightsideItem(array)
|
|||||||
button#rightside-config(type="button" title=_p("rightside.setting"))
|
button#rightside-config(type="button" title=_p("rightside.setting"))
|
||||||
i.fas.fa-cog.fa-spin
|
i.fas.fa-cog.fa-spin
|
||||||
else
|
else
|
||||||
if is_post()
|
if globalPageType === 'post'
|
||||||
if (readmode || translate.enable || (darkmode.enable && darkmode.button))
|
if (readmode || translate.enable || (darkmode.enable && darkmode.button))
|
||||||
button#rightside-config(type="button" title=_p("rightside.setting"))
|
button#rightside-config(type="button" title=_p("rightside.setting"))
|
||||||
i.fas.fa-cog.fa-spin
|
i.fas.fa-cog.fa-spin
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ if theme.menu
|
|||||||
#sidebar
|
#sidebar
|
||||||
#menu-mask
|
#menu-mask
|
||||||
#sidebar-menus
|
#sidebar-menus
|
||||||
.avatar-img.is-center
|
.avatar-img.text-center
|
||||||
img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
|
img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.flink)}'` alt="avatar")
|
||||||
.site-data.is-center
|
.site-data.text-center
|
||||||
a(href=url_for(config.archive_dir) + '/')
|
a(href=`${url_for(config.archive_dir)}/`)
|
||||||
.headline= _p('aside.articles')
|
.headline= _p('aside.articles')
|
||||||
.length-num= site.posts.length
|
.length-num= site.posts.length
|
||||||
a(href=url_for(config.tag_dir) + '/' )
|
a(href=`${url_for(config.tag_dir)}/`)
|
||||||
.headline= _p('aside.tags')
|
.headline= _p('aside.tags')
|
||||||
.length-num= site.tags.length
|
.length-num= site.tags.length
|
||||||
a(href=url_for(config.category_dir) + '/')
|
a(href=`${url_for(config.category_dir)}/`)
|
||||||
.headline= _p('aside.categories')
|
.headline= _p('aside.categories')
|
||||||
.length-num= site.categories.length
|
.length-num= site.categories.length
|
||||||
|
|
||||||
|
|||||||
51
layout/includes/third-party/abcjs/abcjs.pug
vendored
51
layout/includes/third-party/abcjs/abcjs.pug
vendored
@@ -1,17 +1,46 @@
|
|||||||
script.
|
script.
|
||||||
(() => {
|
(function() {
|
||||||
const abcjsInit = () => {
|
const abcjsInit = function() {
|
||||||
const abcjsFn = () => {
|
const abcjsFn = function() {
|
||||||
document.querySelectorAll(".abc-music-sheet").forEach(ele => {
|
setTimeout(function() {
|
||||||
if (ele.children.length > 0) return
|
const sheets = document.querySelectorAll(".abc-music-sheet")
|
||||||
ABCJS.renderAbc(ele, ele.innerHTML, {responsive: 'resize'})
|
for (let i = 0; i < sheets.length; i++) {
|
||||||
})
|
const ele = sheets[i]
|
||||||
|
if (ele.children.length > 0) continue
|
||||||
|
|
||||||
|
// Parse parameters from data-params attribute
|
||||||
|
let params = {}
|
||||||
|
const dp = ele.getAttribute("data-params")
|
||||||
|
if (dp) {
|
||||||
|
try {
|
||||||
|
params = JSON.parse(dp)
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to parse data-params:", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeof ABCJS === 'object' ? abcjsFn()
|
// Merge parsed parameters with the responsive option
|
||||||
: btf.getScript('!{url_for(theme.asset.abcjs_basic_js)}').then(abcjsFn)
|
// Ensures params content appears before responsive
|
||||||
|
const options = { ...params, responsive: "resize" }
|
||||||
|
|
||||||
|
// Render the music score using ABCJS.renderAbc
|
||||||
|
ABCJS.renderAbc(ele, ele.innerHTML, options)
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.pjax ? abcjsInit() : window.addEventListener('load', abcjsInit)
|
if (typeof ABCJS === "object") {
|
||||||
btf.addGlobalFn('encrypt', abcjsInit, 'abcjs')
|
abcjsFn()
|
||||||
|
} else {
|
||||||
|
btf.getScript("!{url_for(theme.asset.abcjs_basic_js)}").then(abcjsFn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.pjax) {
|
||||||
|
abcjsInit()
|
||||||
|
} else {
|
||||||
|
window.addEventListener("load", abcjsInit)
|
||||||
|
}
|
||||||
|
|
||||||
|
btf.addGlobalFn("encrypt", abcjsInit, "abcjs")
|
||||||
})()
|
})()
|
||||||
5
layout/includes/third-party/abcjs/index.pug
vendored
5
layout/includes/third-party/abcjs/index.pug
vendored
@@ -1,6 +1,3 @@
|
|||||||
if theme.abcjs.enable
|
if theme.abcjs.enable
|
||||||
if theme.abcjs.per_page
|
if theme.abcjs.per_page && (['post','page'].includes(globalPageType)) || page.abcjs
|
||||||
if is_post() || is_page()
|
|
||||||
include ./abcjs.pug
|
|
||||||
else if page.abcjs
|
|
||||||
include ./abcjs.pug
|
include ./abcjs.pug
|
||||||
|
|||||||
24
layout/includes/third-party/chat/chatra.pug
vendored
24
layout/includes/third-party/chat/chatra.pug
vendored
@@ -1,6 +1,12 @@
|
|||||||
//- https://chatra.io/help/api/
|
//- https://chatra.io/help/api/
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
window.ChatraID = '#{theme.chatra.id}'
|
||||||
|
window.Chatra = window.Chatra || function() {
|
||||||
|
(window.Chatra.q = window.Chatra.q || []).push(arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
btf.getScript('https://call.chatra.io/chatra.js').then(() => {
|
||||||
const isChatBtn = !{theme.chat.rightside_button}
|
const isChatBtn = !{theme.chat.rightside_button}
|
||||||
const isChatHideShow = !{theme.chat.button_hide_show}
|
const isChatHideShow = !{theme.chat.button_hide_show}
|
||||||
|
|
||||||
@@ -17,26 +23,16 @@ script.
|
|||||||
|
|
||||||
window.ChatraSetup = { startHidden: true }
|
window.ChatraSetup = { startHidden: true }
|
||||||
|
|
||||||
window.chatBtnFn = () => {
|
window.chatBtnFn = () => document.getElementById('chatra').classList.contains('chatra--expanded') ? close() : open()
|
||||||
document.getElementById('chatra').classList.contains('chatra--expanded') ? close() : open()
|
|
||||||
}
|
document.getElementById('chat-btn').style.display = 'block'
|
||||||
} else if (isChatHideShow) {
|
} else if (isChatHideShow) {
|
||||||
window.chatBtn = {
|
window.chatBtn = {
|
||||||
hide: () => Chatra('hide'),
|
hide: () => Chatra('hide'),
|
||||||
show: () => Chatra('show')
|
show: () => Chatra('show')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
(function(d, w, c) {
|
|
||||||
w.ChatraID = '#{theme.chatra.id}'
|
|
||||||
var s = d.createElement('script')
|
|
||||||
w[c] = w[c] || function() {
|
|
||||||
(w[c].q = w[c].q || []).push(arguments)
|
|
||||||
}
|
|
||||||
s.async = true
|
|
||||||
s.src = 'https://call.chatra.io/chatra.js'
|
|
||||||
if (d.head) d.head.appendChild(s)
|
|
||||||
})(document, window, 'Chatra')
|
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
15
layout/includes/third-party/chat/crisp.pug
vendored
15
layout/includes/third-party/chat/crisp.pug
vendored
@@ -1,16 +1,9 @@
|
|||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
window.$crisp = [];
|
window.$crisp = ['safe', true]
|
||||||
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}";
|
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}"
|
||||||
(function () {
|
|
||||||
d = document;
|
|
||||||
s = d.createElement("script");
|
|
||||||
s.src = "https://client.crisp.chat/l.js";
|
|
||||||
s.async = 1;
|
|
||||||
d.getElementsByTagName("head")[0].appendChild(s);
|
|
||||||
})();
|
|
||||||
$crisp.push(["safe", true])
|
|
||||||
|
|
||||||
|
btf.getScript('https://client.crisp.chat/l.js').then(() => {
|
||||||
const isChatBtn = !{theme.chat.rightside_button}
|
const isChatBtn = !{theme.chat.rightside_button}
|
||||||
const isChatHideShow = !{theme.chat.button_hide_show}
|
const isChatHideShow = !{theme.chat.button_hide_show}
|
||||||
|
|
||||||
@@ -28,10 +21,12 @@ script.
|
|||||||
|
|
||||||
window.chatBtnFn = () => $crisp.is("chat:visible") ? close() : open()
|
window.chatBtnFn = () => $crisp.is("chat:visible") ? close() : open()
|
||||||
|
|
||||||
|
document.getElementById('chat-btn').style.display = 'block'
|
||||||
} else if (isChatHideShow) {
|
} else if (isChatHideShow) {
|
||||||
window.chatBtn = {
|
window.chatBtn = {
|
||||||
hide: () => $crisp.push(["do", "chat:hide"]),
|
hide: () => $crisp.push(["do", "chat:hide"]),
|
||||||
show: () => $crisp.push(["do", "chat:show"])
|
show: () => $crisp.push(["do", "chat:show"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
})()
|
})()
|
||||||
40
layout/includes/third-party/chat/daovoice.pug
vendored
40
layout/includes/third-party/chat/daovoice.pug
vendored
@@ -1,40 +0,0 @@
|
|||||||
//- https://guide.daocloud.io/daovoice/javascript-api-5869833.html
|
|
||||||
script.
|
|
||||||
(() => {
|
|
||||||
(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/!{theme.daovoice.app_id}.js","daovoice")
|
|
||||||
|
|
||||||
const isChatBtn = !{theme.chat.rightside_button}
|
|
||||||
const isChatHideShow = !{theme.chat.button_hide_show}
|
|
||||||
|
|
||||||
daovoice('init', {
|
|
||||||
app_id: '!{theme.daovoice.app_id}',},{
|
|
||||||
launcher: {
|
|
||||||
disableLauncherIcon: isChatBtn
|
|
||||||
},
|
|
||||||
});
|
|
||||||
daovoice('update');
|
|
||||||
|
|
||||||
if (isChatBtn) {
|
|
||||||
window.chatBtnFn = () => {
|
|
||||||
const isShow = document.getElementById('daodream-messenger').classList.contains('daodream-messenger-active')
|
|
||||||
isShow ? daovoice('hide') : daovoice('show')
|
|
||||||
}
|
|
||||||
} else if (isChatHideShow) {
|
|
||||||
window.chatBtn = {
|
|
||||||
hide: () => {
|
|
||||||
daovoice('update', {},{
|
|
||||||
launcher: {
|
|
||||||
disableLauncherIcon: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
show: () => {
|
|
||||||
daovoice('update', {}, {
|
|
||||||
launcher: {
|
|
||||||
disableLauncherIcon: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
2
layout/includes/third-party/chat/index.pug
vendored
2
layout/includes/third-party/chat/index.pug
vendored
@@ -3,7 +3,5 @@ case theme.chat.use
|
|||||||
include ./chatra.pug
|
include ./chatra.pug
|
||||||
when 'tidio'
|
when 'tidio'
|
||||||
include ./tidio.pug
|
include ./tidio.pug
|
||||||
when 'daovoice'
|
|
||||||
include ./daovoice.pug
|
|
||||||
when 'crisp'
|
when 'crisp'
|
||||||
include ./crisp.pug
|
include ./crisp.pug
|
||||||
6
layout/includes/third-party/chat/tidio.pug
vendored
6
layout/includes/third-party/chat/tidio.pug
vendored
@@ -1,6 +1,6 @@
|
|||||||
script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async)
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
btf.getScript('//code.tidio.co/!{theme.tidio.public_key}.js').then(() => {
|
||||||
const isChatBtn = !{theme.chat.rightside_button}
|
const isChatBtn = !{theme.chat.rightside_button}
|
||||||
const isChatHideShow = !{theme.chat.button_hide_show}
|
const isChatHideShow = !{theme.chat.button_hide_show}
|
||||||
|
|
||||||
@@ -31,11 +31,15 @@ script.
|
|||||||
if (!window.tidioChatApi) return
|
if (!window.tidioChatApi) return
|
||||||
isShow ? close() : open()
|
isShow ? close() : open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById('chat-btn').style.display = 'block'
|
||||||
|
|
||||||
} else if (isChatHideShow) {
|
} else if (isChatHideShow) {
|
||||||
window.chatBtn = {
|
window.chatBtn = {
|
||||||
hide: () => window.tidioChatApi && window.tidioChatApi.hide(),
|
hide: () => window.tidioChatApi && window.tidioChatApi.hide(),
|
||||||
show: () => window.tidioChatApi && window.tidioChatApi.show()
|
show: () => window.tidioChatApi && window.tidioChatApi.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|||||||
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.pageType === 'shuoshuo'
|
||||||
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)
|
||||||
|
|||||||
43
layout/includes/third-party/comments/disqus.pug
vendored
43
layout/includes/third-party/comments/disqus.pug
vendored
@@ -4,29 +4,43 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const disqus_config = function () {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
|
||||||
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,11 +61,18 @@ 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 {
|
||||||
loadDisqus()
|
loadDisqus()
|
||||||
!{ count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : '' }
|
!{ count ? `GLOBAL_CONFIG_SITE.pageType === 'post' && getCount()` : '' }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.loadOtherComment = loadDisqus
|
window.loadOtherComment = loadDisqus
|
||||||
|
|||||||
@@ -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.pageType === 'shuoshuo'== 'shuoshuo'
|
||||||
|
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,11 +68,18 @@ 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 {
|
||||||
loadDisqusjs()
|
loadDisqusjs()
|
||||||
!{ theme.comments.count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : '' }
|
!{ theme.comments.count ? `GLOBAL_CONFIG_SITE.pageType === 'post' && getCount()` : '' }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.loadOtherComment = loadDisqusjs
|
window.loadOtherComment = loadDisqusjs
|
||||||
|
|||||||
@@ -3,17 +3,28 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(()=>{
|
(()=>{
|
||||||
const loadFBComment = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'== 'shuoshuo'
|
||||||
|
|
||||||
|
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()
|
||||||
|
|||||||
50
layout/includes/third-party/comments/giscus.pug
vendored
50
layout/includes/third-party/comments/giscus.pug
vendored
@@ -5,26 +5,49 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
|
||||||
|
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,6 +66,13 @@ 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()
|
||||||
|
|||||||
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.pageType === 'shuoshuo'
|
||||||
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()
|
||||||
|
|||||||
24
layout/includes/third-party/comments/livere.pug
vendored
24
layout/includes/third-party/comments/livere.pug
vendored
@@ -2,7 +2,22 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const loadLivere = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
|
||||||
|
|
||||||
|
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()
|
||||||
|
|||||||
@@ -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.pageType === 'shuoshuo'
|
||||||
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')
|
||||||
|
|
||||||
|
const getCount = () => document.querySelector('.remark42__counter') && loadScript('!{host}/web/count.js')
|
||||||
|
|
||||||
|
const destroyRemark42 = () => window.remark42Instance && window.remark42Instance.destroy()
|
||||||
|
|
||||||
|
const initRemark42 = remark_config => {
|
||||||
if (window.REMARK42) {
|
if (window.REMARK42) {
|
||||||
if (this.remark42Instance) {
|
destroyRemark42()
|
||||||
this.remark42Instance.destroy()
|
window.remark42Instance = window.REMARK42.createInstance({
|
||||||
}
|
|
||||||
|
|
||||||
this.remark42Instance = window.REMARK42.createInstance({
|
|
||||||
...remark_config
|
...remark_config
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCount () {
|
const loadRemark42 = (el, path) => {
|
||||||
const ele = document.querySelector('.remark42__counter')
|
if (isShuoshuo) {
|
||||||
if (ele) {
|
window.shuoshuoComment.destroyRemark42 = () => {
|
||||||
const s = document.createElement('script')
|
destroyRemark42()
|
||||||
s.src = remark_config.host + '/web/counter.js'
|
if (el.children.length) {
|
||||||
s.defer = true
|
el.innerHTML = ''
|
||||||
document.head.appendChild(s)
|
el.classList.add('no-comment')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRemark42 () {
|
window.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
|
||||||
|
}
|
||||||
|
|
||||||
if (window.REMARK42) {
|
if (window.REMARK42) {
|
||||||
this.initRemark42()
|
initRemark42(remark_config)
|
||||||
getCount()
|
getCount()
|
||||||
} else {
|
} else {
|
||||||
addRemark42()
|
addRemark42()
|
||||||
window.addEventListener('REMARK42::ready', () => {
|
window.addEventListener('REMARK42::ready', () => {
|
||||||
this.initRemark42()
|
initRemark42(remark_config)
|
||||||
getCount()
|
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 (isShuoshuo) {
|
||||||
|
'!{theme.comments.use[0]}' === 'Remark42'
|
||||||
|
? window.shuoshuoComment = { loadComment: loadRemark42 }
|
||||||
|
: window.loadOtherComment = loadRemark42
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
|
||||||
else loadRemark42()
|
else loadRemark42()
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
window.loadOtherComment = loadRemark42
|
||||||
loadRemark42()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
37
layout/includes/third-party/comments/twikoo.pug
vendored
37
layout/includes/third-party/comments/twikoo.pug
vendored
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
|
||||||
|
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.pageType === 'post' && 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.pageType === 'shuoshuo'
|
||||||
|
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()
|
||||||
|
|||||||
44
layout/includes/third-party/comments/valine.pug
vendored
44
layout/includes/third-party/comments/valine.pug
vendored
@@ -7,25 +7,48 @@ if site.data.valine
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
(() => {
|
(() => {
|
||||||
const initValine = () => {
|
const isShuoshuo = GLOBAL_CONFIG_SITE.pageType === 'shuoshuo'
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadValine = async () => {
|
new Valine(valineConfig)
|
||||||
if (typeof Valine === 'function') initValine()
|
|
||||||
else {
|
|
||||||
await btf.getScript('!{url_for(theme.asset.valine)}')
|
|
||||||
initValine()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadValine = async (el, path) => {
|
||||||
|
if (typeof Valine === 'function') {
|
||||||
|
initValine(el, path)
|
||||||
|
} else {
|
||||||
|
await btf.getScript('!{url_for(theme.asset.valine)}')
|
||||||
|
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}) {
|
||||||
@@ -35,4 +58,3 @@ script.
|
|||||||
window.loadOtherComment = loadValine
|
window.loadOtherComment = loadValine
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
|||||||
42
layout/includes/third-party/comments/waline.pug
vendored
42
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.pageType === 'shuoshuo'
|
||||||
|
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 = (el, path) => {
|
||||||
}
|
if (initFn) initWaline(initFn, el, path)
|
||||||
|
|
||||||
const loadWaline = () => {
|
|
||||||
if (initFn) initWaline(initFn)
|
|
||||||
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)
|
||||||
|
|||||||
91
layout/includes/third-party/math/chartjs.pug
vendored
Normal file
91
layout/includes/third-party/math/chartjs.pug
vendored
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
- const { fontColor, borderColor, scale_ticks_backdropColor } = theme.chartjs
|
||||||
|
|
||||||
|
script.
|
||||||
|
(() => {
|
||||||
|
const applyThemeDefaultsConfig = theme => {
|
||||||
|
if (theme === 'dark-mode') {
|
||||||
|
Chart.defaults.color = "!{fontColor.dark}"
|
||||||
|
Chart.defaults.borderColor = "!{borderColor.dark}"
|
||||||
|
Chart.defaults.scale.ticks.backdropColor = "!{scale_ticks_backdropColor.dark}"
|
||||||
|
} else {
|
||||||
|
Chart.defaults.color = "!{fontColor.light}"
|
||||||
|
Chart.defaults.borderColor = "!{borderColor.light}"
|
||||||
|
Chart.defaults.scale.ticks.backdropColor = "!{scale_ticks_backdropColor.light}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively traverse the config object and automatically apply theme-specific color schemes
|
||||||
|
const applyThemeConfig = (obj, theme) => {
|
||||||
|
if (typeof obj !== 'object' || obj === null) return
|
||||||
|
|
||||||
|
Object.keys(obj).forEach(key => {
|
||||||
|
const value = obj[key]
|
||||||
|
// If the property is an object and has theme-specific options, apply them
|
||||||
|
if (typeof value === 'object' && value !== null) {
|
||||||
|
if (value[theme]) {
|
||||||
|
obj[key] = value[theme] // Apply the value for the current theme
|
||||||
|
} else {
|
||||||
|
// Recursively process child objects
|
||||||
|
applyThemeConfig(value, theme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const runChartJS = ele => {
|
||||||
|
window.loadChartJS = true
|
||||||
|
|
||||||
|
Array.from(ele).forEach((item, index) => {
|
||||||
|
const chartSrc = item.firstElementChild
|
||||||
|
const chartID = item.getAttribute('data-chartjs-id') || ('chartjs-' + index) // Use custom ID or default ID
|
||||||
|
const width = item.getAttribute('data-width')
|
||||||
|
const existingCanvas = document.getElementById(chartID)
|
||||||
|
|
||||||
|
// If a canvas already exists, remove it to avoid rendering duplicates
|
||||||
|
if (existingCanvas) {
|
||||||
|
existingCanvas.parentNode.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
const chartDefinition = chartSrc.textContent
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
canvas.id = chartID
|
||||||
|
|
||||||
|
const div = document.createElement('div')
|
||||||
|
div.className = 'chartjs-wrap'
|
||||||
|
|
||||||
|
if (width) {
|
||||||
|
div.style.width = width
|
||||||
|
}
|
||||||
|
|
||||||
|
div.appendChild(canvas)
|
||||||
|
chartSrc.insertAdjacentElement('afterend', div)
|
||||||
|
|
||||||
|
const ctx = document.getElementById(chartID).getContext('2d')
|
||||||
|
|
||||||
|
const config = JSON.parse(chartDefinition)
|
||||||
|
|
||||||
|
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark-mode' : 'light-mode'
|
||||||
|
|
||||||
|
// Set default styles (initial setup)
|
||||||
|
applyThemeDefaultsConfig(theme)
|
||||||
|
|
||||||
|
// Automatically traverse the config and apply dual-mode color schemes
|
||||||
|
applyThemeConfig(config, theme)
|
||||||
|
|
||||||
|
new Chart(ctx, config)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadChartJS = () => {
|
||||||
|
const chartJSEle = document.querySelectorAll('#article-container .chartjs-container')
|
||||||
|
if (chartJSEle.length === 0) return
|
||||||
|
|
||||||
|
window.loadChartJS ? runChartJS(chartJSEle) : btf.getScript('!{url_for(theme.asset.chartjs)}').then(() => runChartJS(chartJSEle))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listen for theme change events
|
||||||
|
btf.addGlobalFn('themeChange', loadChartJS, 'chartjs')
|
||||||
|
btf.addGlobalFn('encrypt', loadChartJS, 'chartjs')
|
||||||
|
|
||||||
|
window.pjax ? loadChartJS() : document.addEventListener('DOMContentLoaded', loadChartJS)
|
||||||
|
})()
|
||||||
7
layout/includes/third-party/math/index.pug
vendored
7
layout/includes/third-party/math/index.pug
vendored
@@ -1,11 +1,14 @@
|
|||||||
case theme.math.use
|
case theme.math.use
|
||||||
when 'mathjax'
|
when 'mathjax'
|
||||||
if (theme.math.per_page && (is_post() || is_page())) || page.mathjax
|
if (theme.math.per_page && (['post','page'].includes(globalPageType))) || page.mathjax
|
||||||
include ./mathjax.pug
|
include ./mathjax.pug
|
||||||
|
|
||||||
when 'katex'
|
when 'katex'
|
||||||
if (theme.math.per_page && (is_post() || is_page())) || page.katex
|
if (theme.math.per_page && (['post','page'].includes(globalPageType))) || page.katex
|
||||||
include ./katex.pug
|
include ./katex.pug
|
||||||
|
|
||||||
if theme.mermaid.enable
|
if theme.mermaid.enable
|
||||||
include ./mermaid.pug
|
include ./mermaid.pug
|
||||||
|
|
||||||
|
if theme.chartjs.enable
|
||||||
|
include ./chartjs.pug
|
||||||
@@ -34,7 +34,7 @@ script.
|
|||||||
|
|
||||||
const searchParams = new URLSearchParams({
|
const searchParams = new URLSearchParams({
|
||||||
'site_name': '!{site}',
|
'site_name': '!{site}',
|
||||||
'limit': '!{theme.aside.card_newest_comments.limit}',
|
'limit': '!{newestCommentsLimit * 2}', // Fetch more comments to filter pending comments
|
||||||
})
|
})
|
||||||
|
|
||||||
const getComment = async (ele) => {
|
const getComment = async (ele) => {
|
||||||
@@ -42,7 +42,10 @@ script.
|
|||||||
const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`)
|
const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`)
|
||||||
const result = await res.json()
|
const result = await res.json()
|
||||||
const { avatarCdn, avatarDefault } = await getAvatarValue()
|
const { avatarCdn, avatarDefault } = await getAvatarValue()
|
||||||
const artalk = result.data.map(e => {
|
const artalk = result.data
|
||||||
|
.filter(e => !e.is_pending) // Filter pending comments
|
||||||
|
.slice(0, !{newestCommentsLimit}) // Limit the number of comments
|
||||||
|
.map(e => {
|
||||||
const avatar = avatarCdn && e.email_encrypted ? `${avatarCdn}${e.email_encrypted}?${avatarDefault}` : ''
|
const avatar = avatarCdn && e.email_encrypted ? `${avatarCdn}${e.email_encrypted}?${avatarDefault}` : ''
|
||||||
return {
|
return {
|
||||||
'avatar': avatar,
|
'avatar': avatar,
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ script.
|
|||||||
result += '<div class="aside-list-item">'
|
result += '<div class="aside-list-item">'
|
||||||
|
|
||||||
if (!{theme.aside.card_newest_comments.avatar} && array[i].avatar) {
|
if (!{theme.aside.card_newest_comments.avatar} && array[i].avatar) {
|
||||||
const imgAttr = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
const imgAttr = '!{theme.lazyload.enable && !theme.lazyload.native ? "data-lazy-src" : "src"}'
|
||||||
result += `<a href="${array[i].url}" class="thumbnail"><img ${imgAttr}="${array[i].avatar}" alt="${array[i].nick}"></a>`
|
const lazyloadNative = '!{theme.lazyload.enable && theme.lazyload.native ? "loading=\"lazy\"" : ""}'
|
||||||
|
result += `<a href="${array[i].url}" class="thumbnail"><img ${imgAttr}="${array[i].avatar}" alt="${array[i].nick}" ${lazyloadNative}></a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
result += `<div class="content">
|
result += `<div class="content">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ script.
|
|||||||
const { changeContent, generateHtml, run } = window.newestComments
|
const { changeContent, generateHtml, run } = window.newestComments
|
||||||
|
|
||||||
const getComment = ele => {
|
const getComment = ele => {
|
||||||
fetch('https://disqus.com/api/3.0/forums/listPosts.json?forum=!{forum}&related=thread&limit=!{theme.aside.card_newest_comments.limit}&api_key=!{apiKey}')
|
fetch('https://disqus.com/api/3.0/forums/listPosts.json?forum=!{forum}&related=thread&limit=!{newestCommentsLimit}&api_key=!{apiKey}')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const disqusArray = data.response.map(item => {
|
const disqusArray = data.response.map(item => {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ script.
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getComment = ele => {
|
const getComment = ele => {
|
||||||
fetch('https://api.github.com/repos/!{userRepo}/issues/comments?sort=updated&direction=desc&per_page=!{theme.aside.card_newest_comments.limit}&page=1',{
|
fetch('https://api.github.com/repos/!{userRepo}/issues/comments?sort=updated&direction=desc&per_page=!{newestCommentsLimit}&page=1',{
|
||||||
"headers": {
|
"headers": {
|
||||||
Accept: 'application/vnd.github.v3.html+json'
|
Accept: 'application/vnd.github.v3.html+json'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
- let { use } = theme.comments
|
- let { use } = theme.comments
|
||||||
|
|
||||||
if use
|
if use
|
||||||
- let forum,apiKey,userRepo
|
-
|
||||||
|
let forum,apiKey,userRepo
|
||||||
|
let { limit:newestCommentsLimit } = theme.aside.card_newest_comments
|
||||||
|
if (newestCommentsLimit > 10 || newestCommentsLimit < 1) newestCommentsLimit = 6
|
||||||
|
|
||||||
case use[0]
|
case use[0]
|
||||||
when 'Valine'
|
when 'Valine'
|
||||||
include ./valine.pug
|
include ./valine.pug
|
||||||
|
|||||||
@@ -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', () => {
|
||||||
@@ -6,7 +7,7 @@ script.
|
|||||||
const { changeContent, generateHtml, run } = window.newestComments
|
const { changeContent, generateHtml, run } = window.newestComments
|
||||||
|
|
||||||
const getComment = ele => {
|
const getComment = ele => {
|
||||||
fetch('!{host}/api/v1/last/!{theme.aside.card_newest_comments.limit}?site=!{siteId}')
|
fetch('!{host}/api/v1/last/!{newestCommentsLimit}?site=!{siteId}')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const remark42 = data.map(e => {
|
const remark42 = data.map(e => {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ script.
|
|||||||
twikoo.getRecentComments({
|
twikoo.getRecentComments({
|
||||||
envId: '!{theme.twikoo.envId}',
|
envId: '!{theme.twikoo.envId}',
|
||||||
region: '!{theme.twikoo.region}',
|
region: '!{theme.twikoo.region}',
|
||||||
pageSize: !{theme.aside.card_newest_comments.limit},
|
pageSize: !{newestCommentsLimit},
|
||||||
includeReply: true
|
includeReply: true
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const twikooArray = res.map(e => {
|
const twikooArray = res.map(e => {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ script.
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(`${serverURL}/1.1/classes/Comment?limit=!{theme.aside.card_newest_comments.limit}&order=-createdAt`,settings)
|
fetch(`${serverURL}/1.1/classes/Comment?limit=!{newestCommentsLimit}&order=-createdAt`,settings)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const valineArray = data.results.map(e => {
|
const valineArray = data.results.map(e => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ script.
|
|||||||
|
|
||||||
const getComment = async (ele) => {
|
const getComment = async (ele) => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('!{serverURL}/api/comment?type=recent&count=!{theme.aside.card_newest_comments.limit}', { method: 'GET' })
|
const res = await fetch('!{serverURL}/api/comment?type=recent&count=!{newestCommentsLimit}')
|
||||||
const result = await res.json()
|
const result = await res.json()
|
||||||
const walineArray = result.data.map(e => {
|
const walineArray = result.data.map(e => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
23
layout/includes/third-party/pangu.pug
vendored
23
layout/includes/third-party/pangu.pug
vendored
@@ -1,23 +0,0 @@
|
|||||||
script.
|
|
||||||
(() => {
|
|
||||||
const panguFn = () => {
|
|
||||||
if (typeof pangu === 'object') pangu.autoSpacingPage()
|
|
||||||
else {
|
|
||||||
btf.getScript('!{url_for(theme.asset.pangu)}')
|
|
||||||
.then(() => {
|
|
||||||
pangu.autoSpacingPage()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const panguInit = () => {
|
|
||||||
if (!{theme.pangu.field === 'post'}){
|
|
||||||
GLOBAL_CONFIG_SITE.isPost && panguFn()
|
|
||||||
} else {
|
|
||||||
panguFn()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
btf.addGlobalFn('pjaxComplete', panguInit, 'pangu')
|
|
||||||
document.addEventListener('DOMContentLoaded', panguInit)
|
|
||||||
})()
|
|
||||||
13
layout/includes/third-party/pjax.pug
vendored
13
layout/includes/third-party/pjax.pug
vendored
@@ -7,10 +7,12 @@ if theme.pjax.exclude
|
|||||||
|
|
||||||
- let choose = theme.comments.use
|
- let choose = theme.comments.use
|
||||||
if choose
|
if choose
|
||||||
if theme.Open_Graph_meta.enable && (choose.includes('Livere') || choose.includes('Utterances') || choose.includes('Giscus'))
|
if choose.includes('Livere') || choose.includes('Utterances') || choose.includes('Giscus')
|
||||||
- pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
|
|
||||||
if choose.includes('Utterances') || choose.includes('Giscus')
|
|
||||||
- pjaxSelectors.unshift('link[rel="canonical"]')
|
- pjaxSelectors.unshift('link[rel="canonical"]')
|
||||||
|
if theme.Open_Graph_meta.enable
|
||||||
|
- pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]', 'meta[property="og:description"]')
|
||||||
|
else
|
||||||
|
- pjaxSelectors.unshift('meta[name="description"]')
|
||||||
|
|
||||||
script(src=url_for(theme.asset.pjax))
|
script(src=url_for(theme.asset.pjax))
|
||||||
script.
|
script.
|
||||||
@@ -57,7 +59,10 @@ script.
|
|||||||
|
|
||||||
document.addEventListener('pjax:error', e => {
|
document.addEventListener('pjax:error', e => {
|
||||||
if (e.request.status === 404) {
|
if (e.request.status === 404) {
|
||||||
pjax.loadUrl('!{url_for("/404.html")}')
|
const usePjax = !{theme.pjax && theme.pjax.enable}
|
||||||
|
!{theme.error_404 && theme.error_404.enable}
|
||||||
|
? (usePjax ? pjax.loadUrl('!{url_for("/404.html")}') : window.location.href = '!{url_for("/404.html")}')
|
||||||
|
: window.location.href = e.request.responseURL
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})()
|
})()
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
button.search-close-button
|
button.search-close-button
|
||||||
i.fas.fa-times
|
i.fas.fa-times
|
||||||
|
|
||||||
#loading-database.is-center
|
#loading-database.text-center
|
||||||
i.fas.fa-spinner.fa-pulse
|
i.fas.fa-spinner.fa-pulse
|
||||||
span= ' ' + _p("search.load_data")
|
span= ' ' + _p("search.load_data")
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.addtoany
|
.addtoany
|
||||||
.a2a_kit.a2a_kit_size_32.a2a_default_style
|
.a2a_kit.a2a_kit_size_32.a2a_default_style
|
||||||
- let addtoanyItem = theme.addtoany.item.split(',')
|
- let addtoanyItem = theme.share.addtoany.item.split(',')
|
||||||
each name in addtoanyItem
|
each name in addtoanyItem
|
||||||
a(class="a2a_button_" + name)
|
a(class="a2a_button_" + name)
|
||||||
|
|
||||||
|
|||||||
76
layout/includes/third-party/subtitle.pug
vendored
76
layout/includes/third-party/subtitle.pug
vendored
@@ -22,6 +22,26 @@ script.
|
|||||||
} else {
|
} else {
|
||||||
subtitleType()
|
subtitleType()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
processSubtitle: (content, extraContents = []) => {
|
||||||
|
if (!{effect}) {
|
||||||
|
const sub = !{JSON.stringify(subContent)}.slice()
|
||||||
|
|
||||||
|
if (extraContents.length > 0) {
|
||||||
|
sub.unshift(...extraContents)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof content === 'string') {
|
||||||
|
sub.unshift(content)
|
||||||
|
} else if (Array.isArray(content)) {
|
||||||
|
sub.unshift(...content)
|
||||||
|
}
|
||||||
|
|
||||||
|
sub.length > 0 && typedJSFn.init(sub)
|
||||||
|
} else {
|
||||||
|
document.getElementById('subtitle').textContent = typeof content === 'string' ? content :
|
||||||
|
(Array.isArray(content) && content.length > 0 ? content[0] : '')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btf.addGlobalFn('pjaxSendOnce', () => { typed.destroy() }, 'typedDestroy')
|
btf.addGlobalFn('pjaxSendOnce', () => { typed.destroy() }, 'typedDestroy')
|
||||||
@@ -33,14 +53,12 @@ case source
|
|||||||
fetch('https://v1.hitokoto.cn')
|
fetch('https://v1.hitokoto.cn')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (!{effect}) {
|
|
||||||
const from = '出自 ' + data.from
|
const from = '出自 ' + data.from
|
||||||
const sub = !{JSON.stringify(subContent)}
|
typedJSFn.processSubtitle(data.hitokoto, [from])
|
||||||
sub.unshift(data.hitokoto, from)
|
})
|
||||||
typedJSFn.init(sub)
|
.catch(err => {
|
||||||
} else {
|
console.error('Failed to get the Hitokoto API:', err)
|
||||||
document.getElementById('subtitle').textContent = data.hitokoto
|
typedJSFn.processSubtitle(!{JSON.stringify(subContent)})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
typedJSFn.run(subtitleType)
|
typedJSFn.run(subtitleType)
|
||||||
@@ -48,46 +66,48 @@ case source
|
|||||||
when 2
|
when 2
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
btf.getScript('https://yijuzhan.com/api/word.php?m=js').then(() => {
|
fetch('https://v.api.aa1.cn/api/yiyan/index.php')
|
||||||
const con = str[0]
|
.then(response => response.text())
|
||||||
if (!{effect}) {
|
.then(data => {
|
||||||
const from = '出自 ' + str[1]
|
const reg = /<p>(.*?)<\/p>/g
|
||||||
const sub = !{JSON.stringify(subContent)}
|
const result = reg.exec(data)
|
||||||
sub.unshift(con, from)
|
if (result && result[1]) {
|
||||||
typedJSFn.init(sub)
|
typedJSFn.processSubtitle(result[1])
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('subtitle').textContent = con
|
throw new Error('Failed to parse the return value of the Yiyan API')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('Failed to get the Yiyan API:', err)
|
||||||
|
typedJSFn.processSubtitle(!{JSON.stringify(subContent.length)})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
typedJSFn.run(subtitleType)
|
typedJSFn.run(subtitleType)
|
||||||
|
|
||||||
when 3
|
when 3
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
btf.getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
|
btf.getScript('https://sdk.jinrishi8ci.com/v2/browser/jinrishici.js')
|
||||||
|
.then(() => {
|
||||||
jinrishici.load(result => {
|
jinrishici.load(result => {
|
||||||
if (!{effect}) {
|
if (result && result.data && result.data.content) {
|
||||||
const sub = !{JSON.stringify(subContent)}
|
typedJSFn.processSubtitle(result.data.content)
|
||||||
const content = result.data.content
|
|
||||||
sub.unshift(content)
|
|
||||||
typedJSFn.init(sub)
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('subtitle').textContent = result.data.content
|
throw new Error('Failed to parse the return value of Jinrishici API')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('Failed to get the Jinrishici API:', err)
|
||||||
|
typedJSFn.processSubtitle(!{JSON.stringify(subContent.length)})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
typedJSFn.run(subtitleType)
|
typedJSFn.run(subtitleType)
|
||||||
|
|
||||||
default
|
default
|
||||||
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
if subContent.length > 0
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
if (!{effect}) {
|
typedJSFn.processSubtitle(!{JSON.stringify(subContent)})
|
||||||
typedJSFn.init(!{JSON.stringify(subContent)})
|
|
||||||
} else {
|
|
||||||
document.getElementById("subtitle").textContent = !{JSON.stringify(subContent[0])}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
typedJSFn.run(subtitleType)
|
typedJSFn.run(subtitleType)
|
||||||
@@ -35,7 +35,7 @@ script.
|
|||||||
|
|
||||||
const insertData = async () => {
|
const insertData = async () => {
|
||||||
try {
|
try {
|
||||||
if (GLOBAL_CONFIG_SITE.isPost && config.page_pv) {
|
if (GLOBAL_CONFIG_SITE.pageType === 'post' && config.page_pv) {
|
||||||
const pagePV = document.getElementById('umamiPV')
|
const pagePV = document.getElementById('umamiPV')
|
||||||
if (pagePV) {
|
if (pagePV) {
|
||||||
const data = await getData(true)
|
const data = await getData(true)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
if theme.aside.card_author.enable
|
if theme.aside.card_author.enable
|
||||||
.card-widget.card-info.is-center
|
.card-widget.card-info.text-center
|
||||||
.avatar-img
|
.avatar-img
|
||||||
img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
|
img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
|
||||||
.author-info-name= config.author
|
.author-info-name= config.author
|
||||||
|
|||||||
@@ -12,4 +12,3 @@
|
|||||||
.toc-content.toc-div-class(class=tocExpandClass style="display:none")!=toc(page.origin, {list_number: tocNumber})
|
.toc-content.toc-div-class(class=tocExpandClass style="display:none")!=toc(page.origin, {list_number: tocNumber})
|
||||||
else
|
else
|
||||||
.toc-content(class=tocExpandClass)!=toc(page.content, {list_number: tocNumber})
|
.toc-content(class=tocExpandClass)!=toc(page.content, {list_number: tocNumber})
|
||||||
|
|
||||||
@@ -6,40 +6,39 @@ if theme.aside.card_webinfo.enable
|
|||||||
.webinfo
|
.webinfo
|
||||||
if theme.aside.card_webinfo.post_count
|
if theme.aside.card_webinfo.post_count
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.article_name') + " :"
|
.item-name= `${_p('aside.card_webinfo.article_name')} :`
|
||||||
.item-count= site.posts.length
|
.item-count= site.posts.length
|
||||||
if theme.aside.card_webinfo.runtime_date
|
if theme.aside.card_webinfo.runtime_date
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.runtime.name') + " :"
|
.item-name= `${_p('aside.card_webinfo.runtime.name')} :`
|
||||||
.item-count#runtimeshow(data-publishDate=date_xml(theme.aside.card_webinfo.runtime_date))
|
.item-count#runtimeshow(data-publishDate=date_xml(theme.aside.card_webinfo.runtime_date))
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.wordcount.enable && theme.wordcount.total_wordcount
|
if theme.wordcount.enable && theme.wordcount.total_wordcount
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name=_p('aside.card_webinfo.site_wordcount') + " :"
|
.item-name= `${_p('aside.card_webinfo.site_wordcount')} :`
|
||||||
.item-count= totalcount(site)
|
.item-count= totalcount(site)
|
||||||
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.site_uv
|
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.site_uv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_uv_name') + " :"
|
.item-name= `${_p('aside.card_webinfo.site_uv_name')} :`
|
||||||
.item-count#umami-site-uv
|
.item-count#umami-site-uv
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if theme.busuanzi.site_uv
|
else if theme.busuanzi.site_uv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_uv_name') + " :"
|
.item-name= `${_p('aside.card_webinfo.site_uv_name')} :`
|
||||||
.item-count#busuanzi_value_site_uv
|
.item-count#busuanzi_value_site_uv
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.site_pv
|
if theme.umami_analytics.enable && theme.umami_analytics.UV_PV.site_pv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_pv_name') + " :"
|
.item-name= `${_p('aside.card_webinfo.site_pv_name')} :`
|
||||||
.item-count#umami-site-pv
|
.item-count#umami-site-pv
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
else if theme.busuanzi.site_pv
|
else if theme.busuanzi.site_pv
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.site_pv_name') + " :"
|
.item-name= `${_p('aside.card_webinfo.site_pv_name')} :`
|
||||||
.item-count#busuanzi_value_site_pv
|
.item-count#busuanzi_value_site_pv
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
if theme.aside.card_webinfo.last_push_date
|
if theme.aside.card_webinfo.last_push_date
|
||||||
.webinfo-item
|
.webinfo-item
|
||||||
.item-name= _p('aside.card_webinfo.last_push_date.name') + " :"
|
.item-name= `${_p('aside.card_webinfo.last_push_date.name')} :`
|
||||||
.item-count#last-push-date(data-lastPushDate=date_xml(Date.now()))
|
.item-count#last-push-date(data-lastPushDate=date_xml(Date.now()))
|
||||||
i.fa-solid.fa-spinner.fa-spin
|
i.fa-solid.fa-spinner.fa-spin
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#aside-content.aside-content
|
#aside-content.aside-content
|
||||||
//- post
|
//- post
|
||||||
if is_post()
|
if globalPageType === 'post'
|
||||||
- const tocStyle = page.toc_style_simple
|
- const tocStyle = page.toc_style_simple
|
||||||
- const tocStyleVal = tocStyle === true || tocStyle === false ? tocStyle : theme.toc.style_simple
|
- const tocStyleVal = tocStyle === true || tocStyle === false ? tocStyle : theme.toc.style_simple
|
||||||
if showToc && tocStyleVal
|
if showToc && tocStyleVal
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ block content
|
|||||||
if top_img === false
|
if top_img === false
|
||||||
include includes/header/post-info.pug
|
include includes/header/post-info.pug
|
||||||
|
|
||||||
article#article-container.post-content!=page.content
|
article#article-container.container.post-content
|
||||||
|
if theme.noticeOutdate.enable && page.noticeOutdate !== false
|
||||||
|
include includes/post/outdate-notice.pug
|
||||||
|
else
|
||||||
|
!=page.content
|
||||||
include includes/post/post-copyright.pug
|
include includes/post/post-copyright.pug
|
||||||
.tag_share
|
.tag_share
|
||||||
if (page.tags.length > 0 && theme.post_meta.post.tags)
|
if (page.tags.length > 0 && theme.post_meta.post.tags)
|
||||||
@@ -29,4 +33,3 @@ block content
|
|||||||
if page.comments !== false && theme.comments.use
|
if page.comments !== false && theme.comments.use
|
||||||
- var commentsJsLoad = true
|
- var commentsJsLoad = true
|
||||||
!=partial('includes/third-party/comments/index', {}, {cache: true})
|
!=partial('includes/third-party/comments/index', {}, {cache: true})
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "5.0.0",
|
"version": "5.3.4",
|
||||||
"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": {
|
||||||
|
|||||||
36
plugins.yml
36
plugins.yml
@@ -1,15 +1,15 @@
|
|||||||
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
|
||||||
version: 1.1.4
|
version: 1.1.4
|
||||||
algolia_search:
|
algolia_search:
|
||||||
name: algoliasearch
|
name: algoliasearch
|
||||||
file: dist/algoliasearch-lite.umd.js
|
file: dist/lite/builds/browser.umd.js
|
||||||
version: 5.7.0
|
version: 5.20.3
|
||||||
aplayer_css:
|
aplayer_css:
|
||||||
name: aplayer
|
name: aplayer
|
||||||
file: dist/APlayer.min.css
|
file: dist/APlayer.min.css
|
||||||
@@ -42,6 +42,10 @@ canvas_ribbon:
|
|||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: dist/canvas-ribbon.min.js
|
file: dist/canvas-ribbon.min.js
|
||||||
version: 1.1.4
|
version: 1.1.4
|
||||||
|
chartjs:
|
||||||
|
name: chart.js
|
||||||
|
file: dist/chart.umd.js
|
||||||
|
version: 4.4.8
|
||||||
clickShowText:
|
clickShowText:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: dist/click-show-text.min.js
|
file: dist/click-show-text.min.js
|
||||||
@@ -62,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.9.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.6.2
|
version: 3.9.0
|
||||||
egjs_infinitegrid:
|
egjs_infinitegrid:
|
||||||
name: '@egjs/infinitegrid'
|
name: '@egjs/infinitegrid'
|
||||||
other_name: egjs-infinitegrid
|
other_name: egjs-infinitegrid
|
||||||
@@ -91,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: 6.6.0
|
version: 6.7.2
|
||||||
gitalk:
|
gitalk:
|
||||||
name: gitalk
|
name: gitalk
|
||||||
file: dist/gitalk.min.js
|
file: dist/gitalk.min.js
|
||||||
@@ -107,17 +111,17 @@ instantpage:
|
|||||||
instantsearch:
|
instantsearch:
|
||||||
name: instantsearch.js
|
name: instantsearch.js
|
||||||
file: dist/instantsearch.production.min.js
|
file: dist/instantsearch.production.min.js
|
||||||
version: 4.74.2
|
version: 4.77.3
|
||||||
katex:
|
katex:
|
||||||
name: katex
|
name: katex
|
||||||
file: dist/katex.min.css
|
file: dist/katex.min.css
|
||||||
other_name: KaTeX
|
other_name: KaTeX
|
||||||
version: 0.16.11
|
version: 0.16.21
|
||||||
katex_copytex:
|
katex_copytex:
|
||||||
name: katex
|
name: katex
|
||||||
file: dist/contrib/copy-tex.min.js
|
file: dist/contrib/copy-tex.min.js
|
||||||
other_name: KaTeX
|
other_name: KaTeX
|
||||||
version: 0.16.11
|
version: 0.16.21
|
||||||
lazyload:
|
lazyload:
|
||||||
name: vanilla-lazyload
|
name: vanilla-lazyload
|
||||||
file: dist/lazyload.iife.min.js
|
file: dist/lazyload.iife.min.js
|
||||||
@@ -133,7 +137,7 @@ medium_zoom:
|
|||||||
mermaid:
|
mermaid:
|
||||||
name: mermaid
|
name: mermaid
|
||||||
file: dist/mermaid.min.js
|
file: dist/mermaid.min.js
|
||||||
version: 11.2.1
|
version: 11.4.1
|
||||||
meting_js:
|
meting_js:
|
||||||
name: butterfly-extsrc
|
name: butterfly-extsrc
|
||||||
file: metingjs/dist/Meting.min.js
|
file: metingjs/dist/Meting.min.js
|
||||||
@@ -148,10 +152,6 @@ pace_js:
|
|||||||
other_name: pace
|
other_name: pace
|
||||||
file: pace.min.js
|
file: pace.min.js
|
||||||
version: 1.2.4
|
version: 1.2.4
|
||||||
pangu:
|
|
||||||
name: pangu
|
|
||||||
file: dist/browser/pangu.min.js
|
|
||||||
version: 4.0.7
|
|
||||||
pjax:
|
pjax:
|
||||||
name: pjax
|
name: pjax
|
||||||
file: pjax.min.js
|
file: pjax.min.js
|
||||||
@@ -190,7 +190,7 @@ snackbar_css:
|
|||||||
twikoo:
|
twikoo:
|
||||||
name: twikoo
|
name: twikoo
|
||||||
file: dist/twikoo.all.min.js
|
file: dist/twikoo.all.min.js
|
||||||
version: 1.6.39
|
version: 1.6.41
|
||||||
typed:
|
typed:
|
||||||
name: typed.js
|
name: typed.js
|
||||||
file: dist/typed.umd.js
|
file: dist/typed.umd.js
|
||||||
@@ -198,14 +198,14 @@ typed:
|
|||||||
valine:
|
valine:
|
||||||
name: valine
|
name: valine
|
||||||
file: dist/Valine.min.js
|
file: dist/Valine.min.js
|
||||||
version: 1.5.2
|
version: 1.5.3
|
||||||
waline_css:
|
waline_css:
|
||||||
name: '@waline/client'
|
name: '@waline/client'
|
||||||
file: dist/waline.css
|
file: dist/waline.css
|
||||||
other_name: waline
|
other_name: waline
|
||||||
version: 3.3.2
|
version: 3.5.5
|
||||||
waline_js:
|
waline_js:
|
||||||
name: '@waline/client'
|
name: '@waline/client'
|
||||||
file: dist/waline.js
|
file: dist/waline.js
|
||||||
other_name: waline
|
other_name: waline
|
||||||
version: 3.3.2
|
version: 3.5.5
|
||||||
|
|||||||
36
scripts/common/postDesc.js
Normal file
36
scripts/common/postDesc.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const { stripHTML, truncate } = require('hexo-util')
|
||||||
|
|
||||||
|
// Truncates the given content to a specified length, removing HTML tags and replacing newlines with spaces.
|
||||||
|
const truncateContent = (content, length) => {
|
||||||
|
return truncate(stripHTML(content), { length, separator: ' ' }).replace(/\n/g, ' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generates a post description based on the provided data and theme configuration.
|
||||||
|
const postDesc = (data, hexo) => {
|
||||||
|
const { description, content, postDesc } = data
|
||||||
|
|
||||||
|
if (postDesc) return postDesc
|
||||||
|
|
||||||
|
const { length, method } = hexo.theme.config.index_post_content
|
||||||
|
|
||||||
|
if (method === false) return
|
||||||
|
|
||||||
|
let result
|
||||||
|
switch (method) {
|
||||||
|
case 1:
|
||||||
|
result = description
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
result = description || truncateContent(content, length)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = truncateContent(content, length)
|
||||||
|
}
|
||||||
|
|
||||||
|
data.postDesc = result
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { truncateContent, postDesc }
|
||||||
@@ -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
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
user_id: null,
|
user_id: null,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
order_by: 'social',
|
order_by: 'social',
|
||||||
lang: 'zh_TW'
|
lang: 'en_US'
|
||||||
},
|
},
|
||||||
twikoo: {
|
twikoo: {
|
||||||
envId: null,
|
envId: null,
|
||||||
@@ -380,9 +380,6 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
tidio: {
|
tidio: {
|
||||||
public_key: null
|
public_key: null
|
||||||
},
|
},
|
||||||
daovoice: {
|
|
||||||
app_id: null
|
|
||||||
},
|
|
||||||
crisp: {
|
crisp: {
|
||||||
website_id: null
|
website_id: null
|
||||||
},
|
},
|
||||||
@@ -512,6 +509,21 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
dark: 'dark'
|
dark: 'dark'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
chartjs: {
|
||||||
|
enable: false,
|
||||||
|
fontColor: {
|
||||||
|
light: 'rgba(0, 0, 0, 0.8)',
|
||||||
|
dark: 'rgba(255, 255, 255, 0.8)'
|
||||||
|
},
|
||||||
|
borderColor: {
|
||||||
|
light: 'rgba(0, 0, 0, 0.1)',
|
||||||
|
dark: 'rgba(255, 255, 255, 0.2)'
|
||||||
|
},
|
||||||
|
scale_ticks_backdropColor: {
|
||||||
|
light: 'transparent',
|
||||||
|
dark: 'transparent'
|
||||||
|
}
|
||||||
|
},
|
||||||
note: {
|
note: {
|
||||||
style: 'flat',
|
style: 'flat',
|
||||||
icons: true,
|
icons: true,
|
||||||
@@ -533,12 +545,9 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
bg_dark: '#1f1f1f'
|
bg_dark: '#1f1f1f'
|
||||||
},
|
},
|
||||||
instantpage: false,
|
instantpage: false,
|
||||||
pangu: {
|
|
||||||
enable: false,
|
|
||||||
field: 'site'
|
|
||||||
},
|
|
||||||
lazyload: {
|
lazyload: {
|
||||||
enable: false,
|
enable: false,
|
||||||
|
native: false,
|
||||||
field: 'site',
|
field: 'site',
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
blur: false
|
blur: false
|
||||||
@@ -555,6 +564,7 @@ hexo.extend.filter.register('before_generate', () => {
|
|||||||
enable: true,
|
enable: true,
|
||||||
option: null
|
option: null
|
||||||
},
|
},
|
||||||
|
structured_data: true,
|
||||||
css_prefix: true,
|
css_prefix: true,
|
||||||
inject: {
|
inject: {
|
||||||
head: null,
|
head: null,
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
const urlFor = require('hexo-util').url_for.bind(hexo)
|
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||||
|
|
||||||
const lazyload = htmlContent => {
|
const lazyload = htmlContent => {
|
||||||
|
if (hexo.theme.config.lazyload.native) {
|
||||||
|
return htmlContent.replace(/(<img.*?)(>)/ig, '$1 loading=\'lazy\'$2')
|
||||||
|
}
|
||||||
|
|
||||||
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'
|
||||||
return htmlContent.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
return htmlContent.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-lazy-src=`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,57 @@
|
|||||||
/**
|
/**
|
||||||
* Butterfly
|
* Random cover for posts
|
||||||
* ramdom cover
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
hexo.extend.filter.register('before_post_render', data => {
|
hexo.extend.generator.register('post', locals => {
|
||||||
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/i
|
const previousIndexes = []
|
||||||
|
|
||||||
|
const getRandomCover = defaultCover => {
|
||||||
|
if (!defaultCover) return false
|
||||||
|
if (!Array.isArray(defaultCover)) return defaultCover
|
||||||
|
|
||||||
|
const coverCount = defaultCover.length
|
||||||
|
|
||||||
|
if (coverCount === 1) {
|
||||||
|
return defaultCover[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
const maxPreviousIndexes = coverCount === 2 ? 1 : (coverCount === 3 ? 2 : 3)
|
||||||
|
|
||||||
|
let index
|
||||||
|
do {
|
||||||
|
index = Math.floor(Math.random() * coverCount)
|
||||||
|
} while (previousIndexes.includes(index) && previousIndexes.length < coverCount)
|
||||||
|
|
||||||
|
previousIndexes.push(index)
|
||||||
|
if (previousIndexes.length > maxPreviousIndexes) {
|
||||||
|
previousIndexes.shift()
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultCover[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleImg = data => {
|
||||||
|
const imgTestReg = /\.(png|jpe?g|gif|svg|webp|avif)(\?.*)?$/i
|
||||||
let { cover: coverVal, top_img: topImg } = data
|
let { cover: coverVal, top_img: topImg } = data
|
||||||
|
|
||||||
// Add path to top_img and cover if post_asset_folder is enabled
|
// Add path to top_img and cover if post_asset_folder is enabled
|
||||||
if (hexo.config.post_asset_folder) {
|
if (hexo.config.post_asset_folder) {
|
||||||
if (topImg && topImg.indexOf('/') === -1 && imgTestReg.test(topImg)) data.top_img = `${data.path}${topImg}`
|
if (topImg && topImg.indexOf('/') === -1 && imgTestReg.test(topImg)) {
|
||||||
if (coverVal && coverVal.indexOf('/') === -1 && imgTestReg.test(coverVal)) data.cover = `${data.path}${coverVal}`
|
data.top_img = `${data.path}${topImg}`
|
||||||
|
}
|
||||||
|
if (coverVal && coverVal.indexOf('/') === -1 && imgTestReg.test(coverVal)) {
|
||||||
|
data.cover = `${data.path}${coverVal}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const randomCoverFn = () => {
|
|
||||||
const { cover: { default_cover: defaultCover } } = hexo.theme.config
|
|
||||||
if (!defaultCover) return false
|
|
||||||
if (!Array.isArray(defaultCover)) return defaultCover
|
|
||||||
const num = Math.floor(Math.random() * defaultCover.length)
|
|
||||||
return defaultCover[num]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coverVal === false) return data
|
if (coverVal === false) return data
|
||||||
|
|
||||||
// If cover is not set, use random cover
|
// If cover is not set, use random cover
|
||||||
if (!coverVal) {
|
if (!coverVal) {
|
||||||
const randomCover = randomCoverFn()
|
const { cover: { default_cover: defaultCover } } = hexo.theme.config
|
||||||
|
const randomCover = getRandomCover(defaultCover)
|
||||||
data.cover = randomCover
|
data.cover = randomCover
|
||||||
coverVal = randomCover // update coverVal
|
coverVal = randomCover // update coverVal
|
||||||
}
|
}
|
||||||
@@ -37,4 +61,22 @@ hexo.extend.filter.register('before_post_render', data => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/hexojs/hexo/blob/master/lib%2Fplugins%2Fgenerator%2Fpost.ts
|
||||||
|
const posts = locals.posts.sort('date').toArray()
|
||||||
|
const { length } = posts
|
||||||
|
|
||||||
|
return posts.map((post, i) => {
|
||||||
|
if (i) post.prev = posts[i - 1]
|
||||||
|
if (i < length - 1) post.next = posts[i + 1]
|
||||||
|
|
||||||
|
post.__post = true
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: handleImg(post),
|
||||||
|
layout: 'post',
|
||||||
|
path: post.path
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,38 +2,68 @@
|
|||||||
|
|
||||||
hexo.extend.helper.register('aside_archives', function (options = {}) {
|
hexo.extend.helper.register('aside_archives', function (options = {}) {
|
||||||
const { config, page, site, url_for, _p } = this
|
const { config, page, site, url_for, _p } = this
|
||||||
const archiveDir = config.archive_dir
|
const {
|
||||||
const { timezone } = config
|
archive_dir: archiveDir,
|
||||||
const lang = toMomentLocale(page.lang || page.language || config.language)
|
timezone,
|
||||||
const type = options.type || 'monthly'
|
language
|
||||||
const format = options.format || (type === 'monthly' ? 'MMMM YYYY' : 'YYYY')
|
} = config
|
||||||
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true
|
|
||||||
const order = options.order || -1
|
// Destructure and set default options with object destructuring
|
||||||
const limit = options.limit
|
const {
|
||||||
|
type = 'monthly',
|
||||||
|
format = type === 'monthly' ? 'MMMM YYYY' : 'YYYY',
|
||||||
|
show_count: showCount = true,
|
||||||
|
order = -1,
|
||||||
|
limit,
|
||||||
|
transform
|
||||||
|
} = options
|
||||||
|
|
||||||
|
// Optimize locale handling
|
||||||
|
const lang = toMomentLocale(page.lang || page.language || language)
|
||||||
|
|
||||||
|
// Memoize comparison function to improve performance
|
||||||
const compareFunc = type === 'monthly'
|
const compareFunc = type === 'monthly'
|
||||||
? (yearA, monthA, yearB, monthB) => yearA === yearB && monthA === monthB
|
? (yearA, monthA, yearB, monthB) => yearA === yearB && monthA === monthB
|
||||||
: (yearA, monthA, yearB, monthB) => yearA === yearB
|
: (yearA, yearB) => yearA === yearB
|
||||||
|
|
||||||
const posts = site.posts.sort('date', order)
|
// Early return if no posts
|
||||||
if (!posts.length) return ''
|
if (!site.posts.length) return ''
|
||||||
|
|
||||||
const data = []
|
// Use reduce for more efficient data processing
|
||||||
posts.forEach(post => {
|
const data = site.posts
|
||||||
|
.sort('date', order)
|
||||||
|
.reduce((acc, post) => {
|
||||||
let date = post.date.clone()
|
let date = post.date.clone()
|
||||||
if (timezone) date = date.tz(timezone)
|
if (timezone) date = date.tz(timezone)
|
||||||
|
|
||||||
const year = date.year()
|
const year = date.year()
|
||||||
const month = date.month() + 1
|
const month = date.month() + 1
|
||||||
|
|
||||||
if (!data.length || !compareFunc(data[data.length - 1].year, data[data.length - 1].month, year, month)) {
|
|
||||||
if (lang) date = date.locale(lang)
|
if (lang) date = date.locale(lang)
|
||||||
data.push({ name: date.format(format), year, month, count: 1 })
|
|
||||||
} else {
|
|
||||||
data[data.length - 1].count++
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const link = item => {
|
// Find or create archive entry
|
||||||
|
const lastEntry = acc[acc.length - 1]
|
||||||
|
if (!lastEntry || !compareFunc(
|
||||||
|
lastEntry.year,
|
||||||
|
lastEntry.month,
|
||||||
|
year,
|
||||||
|
month
|
||||||
|
)) {
|
||||||
|
acc.push({
|
||||||
|
name: date.format(format),
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
count: 1
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
lastEntry.count++
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// Create link generator function
|
||||||
|
const createArchiveLink = item => {
|
||||||
let url = `${archiveDir}/${item.year}/`
|
let url = `${archiveDir}/${item.year}/`
|
||||||
if (type === 'monthly') {
|
if (type === 'monthly') {
|
||||||
url += item.month < 10 ? `0${item.month}/` : `${item.month}/`
|
url += item.month < 10 ? `0${item.month}/` : `${item.month}/`
|
||||||
@@ -41,37 +71,48 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
|||||||
return url_for(url)
|
return url_for(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const len = data.length
|
// Limit results efficiently
|
||||||
const limitLength = limit === 0 ? len : Math.min(len, limit)
|
const limitedData = limit > 0
|
||||||
|
? data.slice(0, Math.min(data.length, limit))
|
||||||
|
: data
|
||||||
|
|
||||||
let result = `
|
// Use template literal for better readability
|
||||||
|
const archiveHeader = `
|
||||||
<div class="item-headline">
|
<div class="item-headline">
|
||||||
<i class="fas fa-archive"></i>
|
<i class="fas fa-archive"></i>
|
||||||
<span>${_p('aside.card_archives')}</span>
|
<span>${_p('aside.card_archives')}</span>
|
||||||
${len > limitLength ? `<a class="card-more-btn" href="${url_for(archiveDir)}/" title="${_p('aside.more_button')}"><i class="fas fa-angle-right"></i></a>` : ''}
|
${data.length > limitedData.length
|
||||||
|
? `<a class="card-more-btn" href="${url_for(archiveDir)}/"
|
||||||
|
title="${_p('aside.more_button')}">
|
||||||
|
<i class="fas fa-angle-right"></i>
|
||||||
|
</a>`
|
||||||
|
: ''}
|
||||||
</div>
|
</div>
|
||||||
<ul class="card-archive-list">
|
|
||||||
`
|
`
|
||||||
|
|
||||||
for (let i = 0; i < limitLength; i++) {
|
// Use map for generating list items, join for performance
|
||||||
const item = data[i]
|
const archiveList = `
|
||||||
result += `
|
<ul class="card-archive-list">
|
||||||
|
${limitedData.map(item => `
|
||||||
<li class="card-archive-list-item">
|
<li class="card-archive-list-item">
|
||||||
<a class="card-archive-list-link" href="${link(item)}">
|
<a class="card-archive-list-link" href="${createArchiveLink(item)}">
|
||||||
<span class="card-archive-list-date">${options.transform ? options.transform(item.name) : item.name}</span>
|
<span class="card-archive-list-date">
|
||||||
${showCount ? `<span class="card-archive-list-count">${item.count}</span>` : ''}
|
${transform ? transform(item.name) : item.name}
|
||||||
|
</span>
|
||||||
|
${showCount
|
||||||
|
? `<span class="card-archive-list-count">${item.count}</span>`
|
||||||
|
: ''}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
`).join('')}
|
||||||
|
</ul>
|
||||||
`
|
`
|
||||||
}
|
|
||||||
|
|
||||||
result += '</ul>'
|
return archiveHeader + archiveList
|
||||||
return result
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const toMomentLocale = function (lang) {
|
// Improved locale conversion function
|
||||||
if (!lang || lang === 'en' || lang === 'default') {
|
const toMomentLocale = lang => {
|
||||||
return 'en'
|
if (!lang || ['en', 'default'].includes(lang)) return 'en'
|
||||||
}
|
|
||||||
return lang.toLowerCase().replace('_', '-')
|
return lang.toLowerCase().replace('_', '-')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const { stripHTML, prettyUrls, truncate } = require('hexo-util')
|
const { truncateContent, postDesc } = require('../common/postDesc')
|
||||||
|
const { prettyUrls } = require('hexo-util')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
const moment = require('moment-timezone')
|
||||||
|
|
||||||
hexo.extend.helper.register('truncate', (content, length) => {
|
hexo.extend.helper.register('truncate', truncateContent)
|
||||||
return truncate(stripHTML(content), { length, separator: ' ' }).replace(/\n/g, ' ')
|
|
||||||
|
hexo.extend.helper.register('postDesc', data => {
|
||||||
|
return postDesc(data, hexo)
|
||||||
})
|
})
|
||||||
|
|
||||||
hexo.extend.helper.register('cloudTags', function (options = {}) {
|
hexo.extend.helper.register('cloudTags', function (options = {}) {
|
||||||
@@ -82,7 +86,7 @@ hexo.extend.helper.register('getBgPath', path => {
|
|||||||
|
|
||||||
const absoluteUrlPattern = /^(?:[a-z][a-z\d+.-]*:)?\/\//i
|
const absoluteUrlPattern = /^(?:[a-z][a-z\d+.-]*:)?\/\//i
|
||||||
const relativeUrlPattern = /^(\.\/|\.\.\/|\/|[^/]+\/).*$/
|
const relativeUrlPattern = /^(\.\/|\.\.\/|\/|[^/]+\/).*$/
|
||||||
const colorPattern = /^(#|rgb|rgba|hsl|hsla|linear-gradient|radial-gradient)/i
|
const colorPattern = /^(#|rgb|rgba|hsl|hsla)/i
|
||||||
|
|
||||||
if (colorPattern.test(path)) {
|
if (colorPattern.test(path)) {
|
||||||
return `background-color: ${path};`
|
return `background-color: ${path};`
|
||||||
@@ -92,3 +96,57 @@ 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
|
||||||
|
const orderByDate = data => data.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))
|
||||||
|
|
||||||
|
// Apply number limit or time limit conditionally
|
||||||
|
const limitData = data => {
|
||||||
|
if (limit && limit.type === 'num' && limit.value > 0) {
|
||||||
|
return data.slice(0, limit.value)
|
||||||
|
} else if (limit && limit.type === 'date' && isValidDate(limit.value)) {
|
||||||
|
const limitDate = Date.parse(limit.value)
|
||||||
|
return data.filter(item => Date.parse(item.date) >= limitDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
orderByDate(data)
|
||||||
|
finalResult = limitData(data)
|
||||||
|
|
||||||
|
// 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
|
||||||
|
})
|
||||||
|
|
||||||
|
hexo.extend.helper.register('getPageType', (page, isHome) => {
|
||||||
|
const { layout, tag, category, type, archive } = page
|
||||||
|
if (layout) return layout
|
||||||
|
if (tag) return 'tag'
|
||||||
|
if (category) return 'category'
|
||||||
|
if (archive) return 'archive'
|
||||||
|
if (type) {
|
||||||
|
if (type === 'tags' || type === 'categories') return type
|
||||||
|
else return 'page'
|
||||||
|
}
|
||||||
|
if (isHome) return 'home'
|
||||||
|
return 'post'
|
||||||
|
})
|
||||||
|
|
||||||
|
hexo.extend.helper.register('getVersion', () => {
|
||||||
|
const { version } = require('../../package.json')
|
||||||
|
return { hexo: hexo.version, theme: version }
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable camelcase */
|
||||||
/**
|
/**
|
||||||
* Butterfly
|
* Butterfly
|
||||||
* Related Posts
|
* Related Posts
|
||||||
@@ -6,12 +7,15 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const { postDesc } = require('../common/postDesc')
|
||||||
|
|
||||||
hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||||
let relatedPosts = []
|
let relatedPosts = []
|
||||||
const tagsData = currentPost.tags
|
const tagsData = currentPost.tags
|
||||||
tagsData.length && tagsData.forEach(function (tag) {
|
tagsData.length && tagsData.forEach(function (tag) {
|
||||||
allPosts.forEach(function (post) {
|
allPosts.forEach(function (post) {
|
||||||
if (currentPost.path !== post.path && isTagRelated(tag.name, post.tags)) {
|
if (currentPost.path !== post.path && isTagRelated(tag.name, post.tags)) {
|
||||||
|
const getPostDesc = post.postDesc || postDesc(post, hexo)
|
||||||
const relatedPost = {
|
const relatedPost = {
|
||||||
title: post.title,
|
title: post.title,
|
||||||
path: post.path,
|
path: post.path,
|
||||||
@@ -19,7 +23,8 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
cover_type: post.cover_type,
|
cover_type: post.cover_type,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
updated: post.updated,
|
updated: post.updated,
|
||||||
created: post.date
|
created: post.date,
|
||||||
|
postDesc: getPostDesc
|
||||||
}
|
}
|
||||||
const index = findItem(relatedPosts, 'path', post.path)
|
const index = findItem(relatedPosts, 'path', post.path)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@@ -50,20 +55,27 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
|||||||
result += '<div class="relatedPosts-list">'
|
result += '<div class="relatedPosts-list">'
|
||||||
|
|
||||||
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
|
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
|
||||||
const cover = relatedPosts[i].cover || 'var(--default-bg-color)'
|
let { cover, title, path, cover_type, created, updated, postDesc } = relatedPosts[i]
|
||||||
const title = this.escape_html(relatedPosts[i].title)
|
const { escape_html, url_for, date } = this
|
||||||
result += `<a href="${this.url_for(relatedPosts[i].path)}" title="${title}">`
|
cover = cover || 'var(--default-bg-color)'
|
||||||
if (relatedPosts[i].cover_type === 'img') {
|
title = escape_html(title)
|
||||||
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
|
const className = postDesc ? 'pagination-related' : 'pagination-related no-desc'
|
||||||
|
result += `<a class="${className}" href="${url_for(path)}" title="${title}">`
|
||||||
|
if (cover_type === 'img') {
|
||||||
|
result += `<img class="cover" src="${url_for(cover)}" alt="cover">`
|
||||||
} else {
|
} else {
|
||||||
result += `<div class="cover" style="background: ${cover}"></div>`
|
result += `<div class="cover" style="background: ${cover}"></div>`
|
||||||
}
|
}
|
||||||
if (dateType === 'created') {
|
if (dateType === 'created') {
|
||||||
result += `<div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> ${this.date(relatedPosts[i].created, hexoConfig.date_format)}</div>`
|
result += `<div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> ${date(created, hexoConfig.date_format)}</div>`
|
||||||
} else {
|
} else {
|
||||||
result += `<div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>`
|
result += `<div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="fas fa-history fa-fw"></i> ${date(updated, hexoConfig.date_format)}</div>`
|
||||||
|
}
|
||||||
|
result += `<div class="info-item-2">${title}</div></div>`
|
||||||
|
|
||||||
|
if (postDesc) {
|
||||||
|
result += `<div class="info-2"><div class="info-item-1">${postDesc}</div></div>`
|
||||||
}
|
}
|
||||||
result += `<div class="title">${title}</div>`
|
|
||||||
result += '</div></a>'
|
result += '</div></a>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
49
scripts/tag/chartjs.js
Normal file
49
scripts/tag/chartjs.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* Butterfly
|
||||||
|
* chartjs
|
||||||
|
* https://www.chartjs.org/
|
||||||
|
* {% chartjs [width, abreast, chartId] %}
|
||||||
|
* <!-- chart -->
|
||||||
|
* <!-- endchart -->
|
||||||
|
* <!-- desc -->
|
||||||
|
* <!-- enddesc -->
|
||||||
|
* {% endchartjs %}
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const { escapeHTML } = require('hexo-util')
|
||||||
|
|
||||||
|
const chartjs = (args, content) => {
|
||||||
|
if (!content) return
|
||||||
|
|
||||||
|
const chartRegex = /<!--\s*chart\s*-->\n([\w\W\s\S]*?)<!--\s*endchart\s*-->/
|
||||||
|
const descRegex = /<!--\s*desc\s*-->\n([\w\W\s\S]*?)<!--\s*enddesc\s*-->/
|
||||||
|
const selfConfig = args.join(' ').trim()
|
||||||
|
|
||||||
|
const [width = '', layout = false, chartId = ''] = selfConfig.split(',').map(s => s.trim())
|
||||||
|
|
||||||
|
const chartMatch = content.match(chartRegex)
|
||||||
|
const descMatch = content.match(descRegex)
|
||||||
|
|
||||||
|
if (!chartMatch) {
|
||||||
|
hexo.log.warn('chartjs tag: chart content is required!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const chartConfig = chartMatch && chartMatch[1] ? chartMatch[1] : ''
|
||||||
|
const descContent = descMatch && descMatch[1] ? descMatch[1] : ''
|
||||||
|
|
||||||
|
const renderedDesc = descContent ? hexo.render.renderSync({ text: descContent, engine: 'markdown' }).trim() : ''
|
||||||
|
|
||||||
|
const descDOM = renderedDesc ? `<div class="chartjs-desc">${renderedDesc}</div>` : ''
|
||||||
|
const abreastClass = layout ? ' chartjs-abreast' : ''
|
||||||
|
const widthStyle = width ? `data-width="${width}%"` : ''
|
||||||
|
|
||||||
|
return `<div class="chartjs-container${abreastClass}" data-chartjs-id="${chartId}" ${widthStyle}>
|
||||||
|
<pre class="chartjs-src" hidden>${escapeHTML(chartConfig)}</pre>
|
||||||
|
${descDOM}
|
||||||
|
</div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.tag.register('chartjs', chartjs, { ends: true })
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
* galleryGroup and gallery
|
* galleryGroup and gallery
|
||||||
* {% galleryGroup [name] [descr] [url] [img] %}
|
* {% galleryGroup [name] [descr] [url] [img] %}
|
||||||
*
|
*
|
||||||
* {% gallery [button],%}
|
* {% gallery [button],[limit],[firstLimit] %}
|
||||||
* {% gallery url,[url],[button] %}
|
* {% gallery url,[url],[button] %}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -11,54 +11,66 @@
|
|||||||
|
|
||||||
const urlFor = require('hexo-util').url_for.bind(hexo)
|
const urlFor = require('hexo-util').url_for.bind(hexo)
|
||||||
|
|
||||||
const gallery = (args, content) => {
|
const DEFAULT_LIMIT = 10
|
||||||
args = args.join(' ').split(',')
|
const DEFAULT_FIRST_LIMIT = 10
|
||||||
let button = false
|
const IMAGE_REGEX = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
|
||||||
let type = 'data'
|
|
||||||
let dataStr = ''
|
|
||||||
|
|
||||||
if (args[0] === 'url') {
|
// Helper functions
|
||||||
[type, dataStr, button] = args // url,[link],[lazyload]
|
const parseGalleryArgs = args => {
|
||||||
dataStr = urlFor(dataStr)
|
const [type, ...rest] = args.join(' ').split(',').map(arg => arg.trim())
|
||||||
} else {
|
return {
|
||||||
[button] = args // [lazyload]
|
isUrl: type === 'url',
|
||||||
const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
|
params: type === 'url' ? rest : [type, ...rest]
|
||||||
let m
|
|
||||||
const arr = []
|
|
||||||
while ((m = regex.exec(content)) !== null) {
|
|
||||||
if (m.index === regex.lastIndex) {
|
|
||||||
regex.lastIndex++
|
|
||||||
}
|
}
|
||||||
arr.push({
|
}
|
||||||
url: m[2],
|
|
||||||
alt: m[1],
|
const parseImageContent = content => {
|
||||||
title: m[3]
|
const images = []
|
||||||
|
let match
|
||||||
|
|
||||||
|
while ((match = IMAGE_REGEX.exec(content)) !== null) {
|
||||||
|
images.push({
|
||||||
|
url: match[2],
|
||||||
|
alt: match[1] || '',
|
||||||
|
title: match[3] || ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataStr = JSON.stringify(arr)
|
return images
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<div class="gallery-container" data-type="${type}" data-button="${button}">
|
const createGalleryHTML = (type, dataStr, button, limit, firstLimit) => {
|
||||||
|
return `<div class="gallery-container" data-type="${type}" data-button="${button}" data-limit="${limit}" data-first="${firstLimit}">
|
||||||
<div class="gallery-items">${dataStr}</div>
|
<div class="gallery-items">${dataStr}</div>
|
||||||
</div>`
|
</div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gallery = (args, content) => {
|
||||||
|
const { isUrl, params } = parseGalleryArgs(args)
|
||||||
|
|
||||||
|
if (isUrl) {
|
||||||
|
const [dataStr, button = false, limit = DEFAULT_LIMIT, firstLimit = DEFAULT_FIRST_LIMIT] = params
|
||||||
|
return createGalleryHTML('url', urlFor(dataStr), button, limit, firstLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
const [button = false, limit = DEFAULT_LIMIT, firstLimit = DEFAULT_FIRST_LIMIT] = params
|
||||||
|
const images = parseImageContent(content)
|
||||||
|
return createGalleryHTML('data', JSON.stringify(images), button, limit, firstLimit)
|
||||||
|
}
|
||||||
|
|
||||||
const galleryGroup = args => {
|
const galleryGroup = args => {
|
||||||
const [name, descr, url, img] = args
|
const [name = '', descr = '', url = '', img = ''] = args.map(arg => arg.trim())
|
||||||
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">
|
<img class="gallery-group-img no-lightbox" src='${urlFor(img)}' alt="Group Image Gallery">
|
||||||
<figcaption>
|
<figcaption>
|
||||||
<div class="gallery-group-name">${name}</div>
|
<div class="gallery-group-name">${name}</div>
|
||||||
<p>${descr}</p>
|
<p>${descr}</p>
|
||||||
<a href='${urlLink}'></a>
|
<a href='${urlFor(url)}'></a>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>`
|
||||||
`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register tags
|
||||||
hexo.extend.tag.register('gallery', gallery, { ends: true })
|
hexo.extend.tag.register('gallery', gallery, { ends: true })
|
||||||
hexo.extend.tag.register('galleryGroup', galleryGroup)
|
hexo.extend.tag.register('galleryGroup', galleryGroup)
|
||||||
|
|||||||
@@ -16,48 +16,35 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const parseArgs = args => {
|
const parseArgs = args => args.join(' ').split(',')
|
||||||
return args.join(' ').split(',')
|
|
||||||
}
|
|
||||||
|
|
||||||
const generateStyle = (bg, color) => {
|
const generateStyle = (bg, color) => {
|
||||||
let style = 'style="'
|
let style = 'style="'
|
||||||
if (bg) {
|
if (bg) style += `background-color: ${bg};`
|
||||||
style += `background-color: ${bg};`
|
if (color) style += `color: ${color}`
|
||||||
}
|
|
||||||
if (color) {
|
|
||||||
style += `color: ${color}`
|
|
||||||
}
|
|
||||||
style += '"'
|
style += '"'
|
||||||
return style
|
return style
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideInline = args => {
|
const hideInline = args => {
|
||||||
const [content, display = 'Click', bg = false, color = false] = parseArgs(args)
|
const [content, display = 'Click', bg = false, color = false] = parseArgs(args)
|
||||||
const group = generateStyle(bg, color)
|
const style = generateStyle(bg, color)
|
||||||
|
return `<span class="hide-inline"><button type="button" class="hide-button" ${style}>${display}</button><span class="hide-content">${content}</span></span>`
|
||||||
return `<span class="hide-inline"><button type="button" class="hide-button" ${group}>${display}
|
|
||||||
</button><span class="hide-content">${content}</span></span>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideBlock = (args, content) => {
|
const hideBlock = (args, content) => {
|
||||||
const [display = 'Click', bg = false, color = false] = parseArgs(args)
|
const [display = 'Click', bg = false, color = false] = parseArgs(args)
|
||||||
const group = generateStyle(bg, color)
|
const style = generateStyle(bg, color)
|
||||||
|
const renderedContent = hexo.render.renderSync({ text: content, engine: 'markdown' })
|
||||||
return `<div class="hide-block"><button type="button" class="hide-button" ${group}>${display}
|
return `<div class="hide-block"><button type="button" class="hide-button" ${style}>${display}</button><div class="hide-content">${renderedContent}</div></div>`
|
||||||
</button><div class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></div>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideToggle = (args, content) => {
|
const hideToggle = (args, content) => {
|
||||||
const [display, bg = false, color = false] = parseArgs(args)
|
const [display, bg = false, color = false] = parseArgs(args)
|
||||||
const group = generateStyle(bg, color)
|
const style = generateStyle(bg, color)
|
||||||
let border = ''
|
const border = bg ? `style="border: 1px solid ${bg}"` : ''
|
||||||
|
const renderedContent = hexo.render.renderSync({ text: content, engine: 'markdown' })
|
||||||
if (bg) {
|
return `<details class="toggle" ${border}><summary class="toggle-button" ${style}>${display}</summary><div class="toggle-content">${renderedContent}</div></details>`
|
||||||
border = `style="border: 1px solid ${bg}"`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `<details class="toggle" ${border}><summary class="toggle-button" ${group}>${display}</summary><div class="toggle-content">${hexo.render.renderSync({ text: content, engine: 'markdown' })}</div></details>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('hideInline', hideInline)
|
hexo.extend.tag.register('hideInline', hideInline)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* inlineImg 圖片
|
* inlineImg
|
||||||
* @param {Array} args 圖片名稱和高度
|
* @param {Array} args - Image name and height
|
||||||
* @param {string} args[0] 圖片名稱
|
* @param {string} args[0] - Image name
|
||||||
* @param {number} args[1] 圖片高度
|
* @param {number} args[1] - Image height
|
||||||
* @returns {string} 圖片標籤
|
* @returns {string} - Image tag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|||||||
@@ -6,17 +6,45 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const score = (args, content) => {
|
const score = (args, content) => {
|
||||||
|
// Escape HTML tags and some special characters, including curly braces
|
||||||
const escapeHtmlTags = s => {
|
const escapeHtmlTags = s => {
|
||||||
const lookup = {
|
const lookup = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
'\'': ''',
|
"'": ''',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>'
|
'>': '>',
|
||||||
|
'{': '{',
|
||||||
|
'}': '}'
|
||||||
}
|
}
|
||||||
return s.replace(/[&"'<>]/g, c => lookup[c])
|
return s.replace(/[&"'<>{}]/g, c => lookup[c])
|
||||||
}
|
|
||||||
return `<div class="abc-music-sheet">${escapeHtmlTags(content)}</div>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('score', score, { ends: true })
|
const trimmed = content.trim()
|
||||||
|
// Split content using six dashes as a delimiter
|
||||||
|
const parts = trimmed.split('------')
|
||||||
|
|
||||||
|
if (parts.length < 2) {
|
||||||
|
// If no delimiter is found, treat the entire content as the score
|
||||||
|
return `<div class="abc-music-sheet">${escapeHtmlTags(trimmed)}</div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
// First part is parameters (JSON string), the rest is the score content
|
||||||
|
const paramPart = parts[0].trim()
|
||||||
|
const scorePart = parts.slice(1).join('------').trim()
|
||||||
|
|
||||||
|
let paramsObj = {}
|
||||||
|
try {
|
||||||
|
paramsObj = JSON.parse(paramPart)
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to parse JSON in score tag:", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use double quotes for data-params attribute value,
|
||||||
|
// ensuring JSON internal double quotes are escaped
|
||||||
|
return `<div class="abc-music-sheet" data-params="${escapeHtmlTags(JSON.stringify(paramsObj))}">
|
||||||
|
${escapeHtmlTags(scorePart)}
|
||||||
|
</div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
hexo.extend.tag.register("score", score, { ends: true })
|
||||||
@@ -1,41 +1,50 @@
|
|||||||
/**
|
/**
|
||||||
* timeline
|
* Timeline tag for Hexo
|
||||||
* by Jerry
|
* Syntax:
|
||||||
|
* {% timeline [headline],[color] %}
|
||||||
|
* <!-- timeline [title] -->
|
||||||
|
* [content]
|
||||||
|
* <!-- endtimeline -->
|
||||||
|
* <!-- timeline [title] -->
|
||||||
|
* [content]
|
||||||
|
* <!-- endtimeline -->
|
||||||
|
* {% endtimeline %}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const timeLineFn = (args, content) => {
|
const timeLineFn = (args, content) => {
|
||||||
const tlBlock = /<!--\s*timeline (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtimeline\s*-->/g
|
// Use named capture groups for better readability
|
||||||
|
const tlBlock = /<!--\s*timeline\s*(?<title>.*?)\s*-->\n(?<content>[\s\S]*?)<!--\s*endtimeline\s*-->/g
|
||||||
|
|
||||||
let result = ''
|
// Pre-compile markdown render function
|
||||||
let color = ''
|
const renderMd = text => hexo.render.renderSync({ text, engine: 'markdown' })
|
||||||
let text = ''
|
|
||||||
if (args.length) {
|
|
||||||
[text, color] = args.join(' ').split(',')
|
|
||||||
const mdContent = hexo.render.renderSync({ text, engine: 'markdown' })
|
|
||||||
result += `<div class='timeline-item headline'><div class='timeline-item-title'><div class='item-circle'>${mdContent}</div></div></div>`
|
|
||||||
}
|
|
||||||
|
|
||||||
const matches = []
|
// Parse arguments more efficiently
|
||||||
let match
|
const [text, color = ''] = args.length ? args.join(' ').split(',') : []
|
||||||
|
|
||||||
while ((match = tlBlock.exec(content)) !== null) {
|
// Build initial headline if text exists
|
||||||
matches.push(match[1])
|
const headline = text
|
||||||
matches.push(match[2])
|
? `<div class='timeline-item headline'>
|
||||||
}
|
<div class='timeline-item-title'>
|
||||||
|
<div class='item-circle'>${renderMd(text)}</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
: ''
|
||||||
|
|
||||||
for (let i = 0; i < matches.length; i += 2) {
|
// Match all timeline blocks in one pass and transform
|
||||||
const tlChildTitle = hexo.render.renderSync({ text: matches[i], engine: 'markdown' })
|
const items = Array.from(content.matchAll(tlBlock))
|
||||||
const tlChildContent = hexo.render.renderSync({ text: matches[i + 1], engine: 'markdown' })
|
.map(({ groups: { title, content } }) =>
|
||||||
|
`<div class='timeline-item'>
|
||||||
|
<div class='timeline-item-title'>
|
||||||
|
<div class='item-circle'>${renderMd(title)}</div>
|
||||||
|
</div>
|
||||||
|
<div class='timeline-item-content'>${renderMd(content)}</div>
|
||||||
|
</div>`
|
||||||
|
)
|
||||||
|
.join('')
|
||||||
|
|
||||||
const tlTitleHtml = `<div class='timeline-item-title'><div class='item-circle'>${tlChildTitle}</div></div>`
|
return `<div class="timeline ${color}">${headline}${items}</div>`
|
||||||
const tlContentHtml = `<div class='timeline-item-content'>${tlChildContent}</div>`
|
|
||||||
|
|
||||||
result += `<div class='timeline-item'>${tlTitleHtml + tlContentHtml}</div>`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `<div class="timeline ${color || ''}">${result}</div>`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hexo.extend.tag.register('timeline', timeLineFn, { ends: true })
|
hexo.extend.tag.register('timeline', timeLineFn, { ends: true })
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ addBorderRadius(x = 6, hide = false)
|
|||||||
.postImgHover
|
.postImgHover
|
||||||
&:hover
|
&:hover
|
||||||
.cover
|
.cover
|
||||||
opacity: .7
|
opacity: .5
|
||||||
transform: scale(1.1)
|
transform: scale(1.1)
|
||||||
|
|
||||||
.cover
|
.cover
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
--preloader-bg: $preloader-bg
|
--preloader-bg: $preloader-bg
|
||||||
--preloader-color: $preloader-word-color
|
--preloader-color: $preloader-word-color
|
||||||
--tab-border-color: $tab-border-color
|
--tab-border-color: $tab-border-color
|
||||||
--tab-botton-bg: $tab-botton-bg
|
--tab-button-bg: $tab-button-bg
|
||||||
--tab-botton-color: $tab-botton-color
|
--tab-button-color: $tab-button-color
|
||||||
--tab-button-hover-bg: $tab-button-hover-bg
|
--tab-button-hover-bg: $tab-button-hover-bg
|
||||||
--tab-button-active-bg: $tab-button-active-bg
|
--tab-button-active-bg: $tab-button-active-bg
|
||||||
--card-bg: $card-bg
|
--card-bg: $card-bg
|
||||||
@@ -179,14 +179,11 @@ if $site-name-font
|
|||||||
#aside-content .author-info-description
|
#aside-content .author-info-description
|
||||||
font-family: $site-name-font
|
font-family: $site-name-font
|
||||||
|
|
||||||
.is-center
|
.text-center
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
.pull-left
|
.text-right
|
||||||
float: left
|
text-align: right
|
||||||
|
|
||||||
.pull-right
|
|
||||||
float: right
|
|
||||||
|
|
||||||
img
|
img
|
||||||
&[src=''],
|
&[src=''],
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ $code-block
|
|||||||
counter-reset: line
|
counter-reset: line
|
||||||
white-space: pre-wrap
|
white-space: pre-wrap
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
pre,
|
pre,
|
||||||
code
|
code
|
||||||
font-size: $code-font-size
|
font-size: $code-font-size
|
||||||
@@ -164,7 +164,7 @@ $code-block
|
|||||||
border: none
|
border: none
|
||||||
|
|
||||||
if $highlight_macstyle
|
if $highlight_macstyle
|
||||||
#article-container
|
.container
|
||||||
figure.highlight
|
figure.highlight
|
||||||
margin: 0 0 24px
|
margin: 0 0 24px
|
||||||
border-radius: 7px
|
border-radius: 7px
|
||||||
@@ -202,7 +202,7 @@ if $highlight_macstyle
|
|||||||
transform: rotate(90deg)
|
transform: rotate(90deg)
|
||||||
|
|
||||||
if hexo-config('code_blocks.height_limit')
|
if hexo-config('code_blocks.height_limit')
|
||||||
#article-container
|
.container
|
||||||
.code-expand-btn
|
.code-expand-btn
|
||||||
position: absolute
|
position: absolute
|
||||||
bottom: 0
|
bottom: 0
|
||||||
@@ -243,7 +243,7 @@ if hexo-config('code_blocks.height_limit')
|
|||||||
opacity: .6
|
opacity: .6
|
||||||
|
|
||||||
if hexo-config('code_blocks.fullpage')
|
if hexo-config('code_blocks.fullpage')
|
||||||
#article-container
|
.container
|
||||||
figure.highlight.code-fullpage
|
figure.highlight.code-fullpage
|
||||||
position: fixed
|
position: fixed
|
||||||
top: 0
|
top: 0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
if $highlight_theme != false
|
if $highlight_theme != false
|
||||||
@require 'diff'
|
@require 'diff'
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
figure.highlight
|
figure.highlight
|
||||||
.line
|
.line
|
||||||
if wordWrap
|
if wordWrap
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ if $prismjs_line_number
|
|||||||
if $highlight_theme != false
|
if $highlight_theme != false
|
||||||
@require 'diff'
|
@require 'diff'
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
pre[class*='language-']
|
pre[class*='language-']
|
||||||
// scrollbar - firefox
|
// scrollbar - firefox
|
||||||
@-moz-document url-prefix()
|
@-moz-document url-prefix()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#article-container
|
.container
|
||||||
pre[class*='language-']
|
pre[class*='language-']
|
||||||
&.line-numbers
|
&.line-numbers
|
||||||
position: relative
|
position: relative
|
||||||
|
|||||||
@@ -159,8 +159,8 @@
|
|||||||
a
|
a
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: row
|
flex-direction: row
|
||||||
padding: 2px 8px
|
|
||||||
margin: 2px 0
|
margin: 2px 0
|
||||||
|
padding: 2px 8px
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
transition: all .3s
|
transition: all .3s
|
||||||
addBorderRadius()
|
addBorderRadius()
|
||||||
@@ -354,11 +354,12 @@
|
|||||||
.headline
|
.headline
|
||||||
@extend .limit-one-line
|
@extend .limit-one-line
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
|
font-size: .95em
|
||||||
|
|
||||||
.length-num
|
.length-num
|
||||||
margin-top: -.32em
|
margin-top: -.45em
|
||||||
color: var(--text-highlight-color)
|
color: var(--text-highlight-color)
|
||||||
font-size: 1.4em
|
font-size: 1.2em
|
||||||
|
|
||||||
@keyframes more-btn-move
|
@keyframes more-btn-move
|
||||||
0%,
|
0%,
|
||||||
|
|||||||
@@ -146,10 +146,11 @@
|
|||||||
position: fixed
|
position: fixed
|
||||||
top: -60px
|
top: -60px
|
||||||
z-index: 91
|
z-index: 91
|
||||||
background: rgba(255, 255, 255, .8)
|
background: rgba(255, 255, 255, .7)
|
||||||
box-shadow: 0 5px 6px -5px alpha($grey, .6)
|
box-shadow: 0 5px 6px -5px alpha($grey, .6)
|
||||||
transition: transform .2s ease-in-out, opacity .2s ease-in-out
|
transition: transform .2s ease-in-out, opacity .2s ease-in-out
|
||||||
will-change: transform
|
will-change: transform
|
||||||
|
backdrop-filter: blur(7px)
|
||||||
|
|
||||||
#blog-info
|
#blog-info
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
@@ -430,6 +431,7 @@
|
|||||||
background-color: lighten($theme-color, 30%)
|
background-color: lighten($theme-color, 30%)
|
||||||
content: ''
|
content: ''
|
||||||
transition: all .3s ease-in-out
|
transition: all .3s ease-in-out
|
||||||
|
addBorderRadius()
|
||||||
|
|
||||||
&:hover
|
&:hover
|
||||||
&:after
|
&:after
|
||||||
|
|||||||
@@ -8,50 +8,32 @@
|
|||||||
background: $theme-paginator-color
|
background: $theme-paginator-color
|
||||||
color: var(--white)
|
color: var(--white)
|
||||||
|
|
||||||
.pagination-info
|
.full-width
|
||||||
position: absolute
|
|
||||||
top: 50%
|
|
||||||
padding: 20px 40px
|
|
||||||
width: 100%
|
|
||||||
transform: translate(0, -50%)
|
|
||||||
|
|
||||||
.prev_info,
|
|
||||||
.next_info
|
|
||||||
@extend .limit-one-line
|
|
||||||
color: var(--white)
|
|
||||||
font-weight: 500
|
|
||||||
|
|
||||||
.next-post
|
|
||||||
.pagination-info
|
|
||||||
text-align: right
|
|
||||||
|
|
||||||
.pull-full
|
|
||||||
width: 100% !important
|
width: 100% !important
|
||||||
|
|
||||||
.prev-post .label,
|
.pagination-related
|
||||||
.next-post .label
|
|
||||||
color: var(--light-grey)
|
|
||||||
text-transform: uppercase
|
|
||||||
font-size: 90%
|
|
||||||
|
|
||||||
.prev-post,
|
|
||||||
.next-post
|
|
||||||
@extend .postImgHover
|
|
||||||
position: relative
|
|
||||||
display: block
|
|
||||||
overflow: hidden
|
|
||||||
width: 50%
|
|
||||||
height: 150px
|
height: 150px
|
||||||
|
|
||||||
+maxWidth768()
|
+minWidth768()
|
||||||
width: 100%
|
flex: 1
|
||||||
|
|
||||||
|
.info-1
|
||||||
|
.info-item-2
|
||||||
|
-webkit-line-clamp: 1
|
||||||
|
|
||||||
|
.info-2
|
||||||
|
.info-item-1
|
||||||
|
-webkit-line-clamp: 2
|
||||||
|
|
||||||
&.pagination-post
|
&.pagination-post
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
margin-top: 40px
|
margin-top: 40px
|
||||||
width: 100%
|
width: 100%
|
||||||
background: $dark-black
|
|
||||||
addBorderRadius()
|
addBorderRadius()
|
||||||
|
display: flex
|
||||||
|
|
||||||
|
+maxWidth768()
|
||||||
|
flex-direction: column
|
||||||
|
|
||||||
.layout
|
.layout
|
||||||
.pagination
|
.pagination
|
||||||
@@ -75,3 +57,50 @@
|
|||||||
|
|
||||||
& > *:not(.space)
|
& > *:not(.space)
|
||||||
box-shadow: none
|
box-shadow: none
|
||||||
|
|
||||||
|
.pagination-related
|
||||||
|
position: relative
|
||||||
|
display: inline-block
|
||||||
|
overflow: hidden
|
||||||
|
background: $dark-black
|
||||||
|
vertical-align: bottom
|
||||||
|
@extend .postImgHover
|
||||||
|
|
||||||
|
&.next-post
|
||||||
|
.info
|
||||||
|
text-align: right
|
||||||
|
|
||||||
|
.info
|
||||||
|
.info-1,
|
||||||
|
.info-2
|
||||||
|
@extend .verticalCenter
|
||||||
|
padding: 20px 40px
|
||||||
|
color: var(--white)
|
||||||
|
transition: transform .3s, opacity .3s
|
||||||
|
|
||||||
|
.info-1
|
||||||
|
.info-item-1
|
||||||
|
color: var(--light-grey)
|
||||||
|
text-transform: uppercase
|
||||||
|
font-size: 90%
|
||||||
|
|
||||||
|
.info-item-2
|
||||||
|
@extend .limit-more-line
|
||||||
|
color: var(--white)
|
||||||
|
font-weight: 500
|
||||||
|
|
||||||
|
.info-2
|
||||||
|
opacity: 0
|
||||||
|
transform: translate(0, 0)
|
||||||
|
|
||||||
|
.info-item-1
|
||||||
|
@extend .limit-more-line
|
||||||
|
|
||||||
|
&:not(.no-desc):hover
|
||||||
|
.info-1
|
||||||
|
opacity: 0
|
||||||
|
transform: translate(0, -100%)
|
||||||
|
|
||||||
|
.info-2
|
||||||
|
opacity: 1
|
||||||
|
transform: translate(0, -50%)
|
||||||
@@ -19,9 +19,9 @@ beautify()
|
|||||||
&:before
|
&:before
|
||||||
position: absolute
|
position: absolute
|
||||||
top: calc(50% - 7px)
|
top: calc(50% - 7px)
|
||||||
|
left: 0
|
||||||
color: $title-prefix-icon-color
|
color: $title-prefix-icon-color
|
||||||
content: $title-prefix-icon
|
content: $title-prefix-icon
|
||||||
left: 0
|
|
||||||
line-height: 1
|
line-height: 1
|
||||||
transition: all .2s ease-out
|
transition: all .2s ease-out
|
||||||
@extend .fontawesomeIcon
|
@extend .fontawesomeIcon
|
||||||
@@ -69,7 +69,7 @@ beautify()
|
|||||||
hr
|
hr
|
||||||
@extend .custom-hr
|
@extend .custom-hr
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
word-wrap: break-word
|
word-wrap: break-word
|
||||||
overflow-wrap: break-word
|
overflow-wrap: break-word
|
||||||
|
|
||||||
@@ -119,16 +119,16 @@ beautify()
|
|||||||
width: fit-content
|
width: fit-content
|
||||||
|
|
||||||
a:not(.headerlink)
|
a:not(.headerlink)
|
||||||
position relative
|
position: relative
|
||||||
z-index 10
|
z-index: 10
|
||||||
|
|
||||||
a.headerlink
|
a.headerlink
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 0
|
top: 0
|
||||||
right: 0
|
right: 0
|
||||||
left 0
|
|
||||||
bottom: 0
|
bottom: 0
|
||||||
width 100%
|
left: 0
|
||||||
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
|
|
||||||
ol,
|
ol,
|
||||||
@@ -236,7 +236,7 @@ beautify()
|
|||||||
&:hover
|
&:hover
|
||||||
text-decoration: none
|
text-decoration: none
|
||||||
|
|
||||||
.post-outdate-notice
|
#post-outdate-notice
|
||||||
position: relative
|
position: relative
|
||||||
margin: 0 0 20px
|
margin: 0 0 20px
|
||||||
padding: .5em 1.2em
|
padding: .5em 1.2em
|
||||||
@@ -244,6 +244,9 @@ beautify()
|
|||||||
color: $noticeOutdate-color
|
color: $noticeOutdate-color
|
||||||
addBorderRadius(3)
|
addBorderRadius(3)
|
||||||
|
|
||||||
|
.num
|
||||||
|
padding: 0 4px
|
||||||
|
|
||||||
if hexo-config('noticeOutdate.style') == 'flat'
|
if hexo-config('noticeOutdate.style') == 'flat'
|
||||||
padding: .5em 1em .5em 2.6em
|
padding: .5em 1em .5em 2.6em
|
||||||
border-left: 5px solid $noticeOutdate-border
|
border-left: 5px solid $noticeOutdate-border
|
||||||
|
|||||||
@@ -8,15 +8,9 @@
|
|||||||
|
|
||||||
& > .relatedPosts-list
|
& > .relatedPosts-list
|
||||||
& > a
|
& > a
|
||||||
position: relative
|
|
||||||
display: inline-block
|
|
||||||
overflow: hidden
|
|
||||||
margin: 3px
|
margin: 3px
|
||||||
width: calc(33.333% - 6px)
|
width: calc(33.333% - 6px)
|
||||||
height: 200px
|
height: 200px
|
||||||
background: $dark-black
|
|
||||||
vertical-align: bottom
|
|
||||||
@extend .postImgHover
|
|
||||||
addBorderRadius()
|
addBorderRadius()
|
||||||
|
|
||||||
+maxWidth768()
|
+maxWidth768()
|
||||||
@@ -27,15 +21,11 @@
|
|||||||
+maxWidth600()
|
+maxWidth600()
|
||||||
width: calc(100% - 4px)
|
width: calc(100% - 4px)
|
||||||
|
|
||||||
.content
|
.info
|
||||||
padding: 0 20px
|
.info-1
|
||||||
@extend .verticalCenter
|
.info-item-2
|
||||||
|
|
||||||
.date
|
|
||||||
color: var(--light-grey)
|
|
||||||
font-size: 90%
|
|
||||||
|
|
||||||
.title
|
|
||||||
@extend .limit-more-line
|
|
||||||
color: var(--white)
|
|
||||||
-webkit-line-clamp: 2
|
-webkit-line-clamp: 2
|
||||||
|
|
||||||
|
.info-2
|
||||||
|
.info-item-1
|
||||||
|
-webkit-line-clamp: 3
|
||||||
@@ -75,6 +75,32 @@ if hexo-config('mermaid.enable')
|
|||||||
pre > code.mermaid
|
pre > code.mermaid
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
if hexo-config('chartjs.enable')
|
||||||
|
.chartjs-container
|
||||||
|
display: flex
|
||||||
|
flex-direction: column
|
||||||
|
justify-content: center
|
||||||
|
align-items: center
|
||||||
|
margin: 0 0 20px
|
||||||
|
text-align: center
|
||||||
|
gap: 20px
|
||||||
|
|
||||||
|
+maxWidth600()
|
||||||
|
.chartjs-wrap
|
||||||
|
width: 100% !important
|
||||||
|
|
||||||
|
&.chartjs-abreast
|
||||||
|
flex-direction: row
|
||||||
|
|
||||||
|
+maxWidth600()
|
||||||
|
flex-direction: column
|
||||||
|
|
||||||
|
.chartjs-wrap
|
||||||
|
width: -webkit-fill-available
|
||||||
|
|
||||||
|
canvas
|
||||||
|
display: inline-block !important
|
||||||
|
|
||||||
.utterances,
|
.utterances,
|
||||||
.fb-comments iframe
|
.fb-comments iframe
|
||||||
width: 100% !important
|
width: 100% !important
|
||||||
@@ -127,7 +153,7 @@ if hexo-config('math.use')
|
|||||||
.aplayer
|
.aplayer
|
||||||
color: $font-black
|
color: $font-black
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
.aplayer
|
.aplayer
|
||||||
margin: 0 0 20px
|
margin: 0 0 20px
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
--preloader-bg: darken(#121212, 2)
|
--preloader-bg: darken(#121212, 2)
|
||||||
--preloader-color: alpha(#FFFFFF, .7)
|
--preloader-color: alpha(#FFFFFF, .7)
|
||||||
--tab-border-color: #2c2c2c
|
--tab-border-color: #2c2c2c
|
||||||
--tab-botton-bg: #2c2c2c
|
--tab-button-bg: #2c2c2c
|
||||||
--tab-botton-color: alpha(#FFFFFF, .7)
|
--tab-button-color: alpha(#FFFFFF, .7)
|
||||||
--tab-button-hover-bg: lighten(#121212, 15)
|
--tab-button-hover-bg: lighten(#121212, 15)
|
||||||
--tab-button-active-bg: #121212
|
--tab-button-active-bg: #121212
|
||||||
--card-bg: #121212
|
--card-bg: #121212
|
||||||
@@ -41,7 +41,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
background-color: alpha($dark-black, .7)
|
background-color: alpha($dark-black, .7)
|
||||||
content: ''
|
content: ''
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
code
|
code
|
||||||
background: #2c2c2c
|
background: #2c2c2c
|
||||||
|
|
||||||
@@ -87,9 +87,9 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark'
|
|||||||
.hide-button,
|
.hide-button,
|
||||||
.btn-beautify,
|
.btn-beautify,
|
||||||
.hl-label,
|
.hl-label,
|
||||||
.post-outdate-notice,
|
#post-outdate-notice,
|
||||||
.error-img,
|
.error-img,
|
||||||
#article-container iframe,
|
.container iframe,
|
||||||
.gist,
|
.gist,
|
||||||
.ads-wrap
|
.ads-wrap
|
||||||
filter: brightness(.8)
|
filter: brightness(.8)
|
||||||
|
|||||||
@@ -77,13 +77,13 @@ if hexo-config('readmode')
|
|||||||
#footer,
|
#footer,
|
||||||
#post > *:not(#post-info):not(.post-content),
|
#post > *:not(#post-info):not(.post-content),
|
||||||
#nav,
|
#nav,
|
||||||
.post-outdate-notice,
|
#post-outdate-notice,
|
||||||
#web_bg,
|
#web_bg,
|
||||||
#rightside,
|
#rightside,
|
||||||
.not-top-img
|
.not-top-img
|
||||||
display: none !important
|
display: none !important
|
||||||
|
|
||||||
#article-container
|
.container
|
||||||
a
|
a
|
||||||
color: #99a9bf
|
color: #99a9bf
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#article-container
|
.container
|
||||||
.flink
|
.flink
|
||||||
margin-bottom: 20px
|
margin-bottom: 20px
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
.shuoshuo-item-header
|
.shuoshuo-item-header
|
||||||
display: flex
|
display: flex
|
||||||
align-items: center
|
align-items: center
|
||||||
|
cursor: default
|
||||||
|
|
||||||
.shuoshuo-avatar
|
.shuoshuo-avatar
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
@@ -36,6 +37,16 @@
|
|||||||
& > *:last-child
|
& > *:last-child
|
||||||
margin-bottom: 0
|
margin-bottom: 0
|
||||||
|
|
||||||
|
.shuoshuo-footer
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
|
||||||
|
&.flex-between
|
||||||
|
justify-content: space-between
|
||||||
|
|
||||||
|
&.flex-end
|
||||||
|
justify-content: flex-end
|
||||||
|
|
||||||
.shuoshuo-tag
|
.shuoshuo-tag
|
||||||
display: inline-block
|
display: inline-block
|
||||||
margin-right: 8px
|
margin-right: 8px
|
||||||
@@ -51,3 +62,17 @@
|
|||||||
&:hover
|
&:hover
|
||||||
background: $light-blue
|
background: $light-blue
|
||||||
color: var(--white)
|
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
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
height: 24px
|
height: 24px
|
||||||
text-align: center
|
text-align: center
|
||||||
line-height: 24px
|
line-height: 24px
|
||||||
|
addBorderRadius()
|
||||||
|
|
||||||
.ais-Pagination-item--selected
|
.ais-Pagination-item--selected
|
||||||
a
|
a
|
||||||
@@ -74,11 +75,11 @@
|
|||||||
overflow-y: overlay
|
overflow-y: overlay
|
||||||
margin: 0 -20px
|
margin: 0 -20px
|
||||||
padding: 0 22px
|
padding: 0 22px
|
||||||
max-height: calc(80vh - 240px)
|
max-height: calc(80vh - 220px)
|
||||||
|
|
||||||
+maxWidth768()
|
+maxWidth768()
|
||||||
max-height: none
|
max-height: none
|
||||||
height: calc(var(--search-height) - 265px)
|
height: calc(var(--search-height) - 235px)
|
||||||
|
|
||||||
#algolia-info
|
#algolia-info
|
||||||
div
|
div
|
||||||
|
|||||||
@@ -19,9 +19,6 @@
|
|||||||
height: 100%
|
height: 100%
|
||||||
border-radius: 0
|
border-radius: 0
|
||||||
|
|
||||||
hr
|
|
||||||
margin: 20px auto
|
|
||||||
|
|
||||||
.search-nav
|
.search-nav
|
||||||
margin: 0 0 14px
|
margin: 0 0 14px
|
||||||
color: $search-color
|
color: $search-color
|
||||||
@@ -40,7 +37,7 @@
|
|||||||
color: $search-color
|
color: $search-color
|
||||||
|
|
||||||
hr
|
hr
|
||||||
margin: 20px auto
|
margin: 15px auto
|
||||||
@extend .custom-hr
|
@extend .custom-hr
|
||||||
|
|
||||||
#search-mask
|
#search-mask
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user