From 6a99a80758ed8809cd5be8b1f00e2fd34f969119 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 29 Dec 2023 23:01:58 +0800 Subject: [PATCH] update --- _config.yml | 3 ++- .../includes/third-party/comments/artalk.pug | 26 +++++++++++-------- .../includes/third-party/comments/waline.pug | 7 +++++ .../newest-comments/github-issues.pug | 7 +++-- layout/includes/widget/card_post_series.pug | 2 +- layout/includes/widget/card_post_toc.pug | 4 +-- package.json | 2 +- plugins.yml | 16 ++++++------ scripts/events/merge_config.js | 3 ++- source/css/_layout/post.styl | 2 ++ 10 files changed, 45 insertions(+), 27 deletions(-) diff --git a/_config.yml b/_config.yml index 96cfa5a..31433bc 100644 --- a/_config.yml +++ b/_config.yml @@ -266,6 +266,7 @@ aside: sort_order: # Don't modify the setting unless you know how it works card_post_series: enable: true + series_title: false # The title shows the series name orderBy: 'date' # Order by title or date order: -1 # Sort of order. 1, asc for ascending; -1, desc for descending @@ -929,7 +930,7 @@ CDN: third_party_provider: jsdelivr # Add version number to url, true or false - version: false + version: true # Custom format # For example: https://cdn.staticfile.org/${cdnjs_name}/${version}/${min_cdnjs_file} diff --git a/layout/includes/third-party/comments/artalk.pug b/layout/includes/third-party/comments/artalk.pug index 700b91a..6354429 100644 --- a/layout/includes/third-party/comments/artalk.pug +++ b/layout/includes/third-party/comments/artalk.pug @@ -3,8 +3,9 @@ script. (() => { + let artalkItem = null const initArtalk = () => { - window.artalkItem = new Artalk(Object.assign({ + artalkItem = Artalk.init(Object.assign({ el: '#artalk-wrap', server: '!{server}', site: '!{site}', @@ -14,18 +15,22 @@ script. },!{JSON.stringify(option)})) if (GLOBAL_CONFIG.lightbox === 'null') return - window.artalkItem.use(ctx => { - ctx.on('list-loaded', () => { - ctx.getCommentList().forEach(comment => { - const $content = comment.getRender().$content - btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])')) - }) + artalkItem.on('list-loaded', () => { + artalkItem.ctx.get('list').getCommentNodes().forEach(comment => { + const $content = comment.getRender().$content + btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])')) }) }) + + const destroyArtalk = () => { + artalkItem.destroy() + } + + btf.addGlobalFn('pjax', destroyArtalk, 'destroyArtalk') } const loadArtalk = async () => { - if (typeof window.artalkItem === 'object') initArtalk() + if (typeof Artalk === 'object') initArtalk() else { await getCSS('!{theme.asset.artalk_css}') await getScript('!{theme.asset.artalk_js}') @@ -37,12 +42,11 @@ script. const artalkWrap = document.getElementById('artalk-wrap') if (!(artalkWrap && artalkWrap.children.length)) return const isDark = theme === 'dark' - window.artalkItem.setDarkMode(isDark) + artalkItem.setDarkMode(isDark) } - btf.addGlobalFn('themeChange', artalkChangeMode, 'artalk') - + if ('!{use[0]}' === 'Artalk' || !!{lazyload}) { if (!{lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk) else loadArtalk() diff --git a/layout/includes/third-party/comments/waline.pug b/layout/includes/third-party/comments/waline.pug index a3bacca..ca35f8a 100644 --- a/layout/includes/third-party/comments/waline.pug +++ b/layout/includes/third-party/comments/waline.pug @@ -12,6 +12,13 @@ script. path: window.location.pathname, comment: !{lazyload ? false : count}, }, !{JSON.stringify(option)})) + + const destroyWaline = () => { + waline.destroy() + } + + btf.addGlobalFn('pjax', destroyWaline, 'destroyWaline') + } const loadWaline = async () => { diff --git a/layout/includes/third-party/newest-comments/github-issues.pug b/layout/includes/third-party/newest-comments/github-issues.pug index d2cb46e..82b4a92 100644 --- a/layout/includes/third-party/newest-comments/github-issues.pug +++ b/layout/includes/third-party/newest-comments/github-issues.pug @@ -17,7 +17,10 @@ script. const findTrueUrl = (array) => { Promise.all(array.map(item => fetch(item.url).then(resp => resp.json()).then(data => { - const urlArray = data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig) + let urlArray = data.body ? data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig) : [] + if (!Array.isArray(urlArray) || urlArray.length === 0) { + urlArray = [`${data.html_url}`] + } if (data.user.login === 'utterances-bot') { return urlArray.pop() } else { @@ -48,7 +51,7 @@ script. const githubArray = data.map(item => { return { 'avatar': item.user.avatar_url, - 'content': changeContent(item.body_html), + 'content': changeContent(item.body_html || item.body), 'nick': item.user.login, 'url': item.issue_url, 'date': item.updated_at, diff --git a/layout/includes/widget/card_post_series.pug b/layout/includes/widget/card_post_series.pug index c216929..38f857b 100644 --- a/layout/includes/widget/card_post_series.pug +++ b/layout/includes/widget/card_post_series.pug @@ -3,7 +3,7 @@ if theme.aside.card_post_series.enable .card-widget.card-post-series .item-headline i.fa-solid.fa-layer-group - span= _p('aside.card_post_series') + span= theme.aside.card_post_series.series_title ? page.series : _p('aside.card_post_series') .aside-list each item in array[page.series] - const { path, title = _p('no_title'), cover, cover_type, date:dateA } = item diff --git a/layout/includes/widget/card_post_toc.pug b/layout/includes/widget/card_post_toc.pug index 4154221..b811210 100644 --- a/layout/includes/widget/card_post_toc.pug +++ b/layout/includes/widget/card_post_toc.pug @@ -1,5 +1,5 @@ -- let tocNumber = page.toc_number !== undefined ? page.toc_number : theme.toc.number -- let tocExpand = page.toc_expand !== undefined ? page.toc_expand : theme.toc.expand +- let tocNumber = typeof page.toc_number === 'boolean' ? page.toc_number : theme.toc.number +- let tocExpand = typeof page.toc_expand === 'boolean' ? page.toc_expand : theme.toc.expand - let tocExpandClass = tocExpand ? 'is-expand' : '' #card-toc.card-widget diff --git a/package.json b/package.json index e5d2510..71a1d00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "4.11.0", + "version": "4.12.0", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/plugins.yml b/plugins.yml index 31ee1b5..ada0677 100644 --- a/plugins.yml +++ b/plugins.yml @@ -1,11 +1,11 @@ algolia_search: name: algoliasearch file: dist/algoliasearch-lite.umd.js - version: 4.20.0 + version: 4.22.0 instantsearch: name: instantsearch.js file: dist/instantsearch.production.min.js - version: 4.60.0 + version: 4.63.0 pjax: name: pjax file: pjax.min.js @@ -37,7 +37,7 @@ disqusjs_css: twikoo: name: twikoo file: dist/twikoo.all.min.js - version: 1.6.25 + version: 1.6.29 waline_js: name: '@waline/client' file: dist/waline.js @@ -121,12 +121,12 @@ pangu: fancybox_css: name: '@fancyapps/ui' file: dist/fancybox/fancybox.css - version: 5.0.28 + version: 5.0.32 other_name: fancyapps-ui fancybox: name: '@fancyapps/ui' file: dist/fancybox/fancybox.umd.js - version: 5.0.28 + version: 5.0.32 other_name: fancyapps-ui medium_zoom: name: medium-zoom @@ -144,7 +144,7 @@ fontawesome: name: '@fortawesome/fontawesome-free' file: css/all.min.css other_name: font-awesome - version: 6.4.2 + version: 6.5.1 flickr_justified_gallery_js: name: flickr-justified-gallery file: dist/fjGallery.min.js @@ -188,11 +188,11 @@ prismjs_autoloader: artalk_js: name: artalk file: dist/Artalk.js - version: 2.6.4 + version: 2.7.3 artalk_css: name: artalk file: dist/Artalk.css - version: 2.6.4 + version: 2.7.3 pace_js: name: pace-js other_name: pace diff --git a/scripts/events/merge_config.js b/scripts/events/merge_config.js index a7540b9..e4a2342 100644 --- a/scripts/events/merge_config.js +++ b/scripts/events/merge_config.js @@ -181,6 +181,7 @@ hexo.extend.filter.register('before_generate', () => { }, card_post_series: { enable: true, + series_title: false, orderBy: 'date', order: -1 } @@ -534,7 +535,7 @@ hexo.extend.filter.register('before_generate', () => { CDN: { internal_provider: 'local', third_party_provider: 'jsdelivr', - version: false, + version: true, custom_format: null, option: null } diff --git a/source/css/_layout/post.styl b/source/css/_layout/post.styl index abbd58e..b5a8583 100644 --- a/source/css/_layout/post.styl +++ b/source/css/_layout/post.styl @@ -115,6 +115,8 @@ beautify() h4, h5, h6 + width: fit-content + a:not(.headerlink) position relative z-index 10