diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index 38c3309..a291861 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -6,7 +6,7 @@ labels: issue: body: | This issue has been closed because it does not meet our Issue template. - Please read our [guidelines for contributing](https://github.com/next-theme/hexo-theme-next/blob/master/.github/CONTRIBUTING.md#how-can-i-contribute)." + Please read our [guidelines for contributing](https://github.com/next-theme/hexo-theme-next/blob/master/.github/CONTRIBUTING.md#how-can-i-contribute). action: close - name: Need More Info labeled: diff --git a/scripts/filters/post.js b/scripts/filters/post.js index 23c8452..f1ea4cb 100644 --- a/scripts/filters/post.js +++ b/scripts/filters/post.js @@ -2,6 +2,8 @@ 'use strict'; +const { parse } = require('url'); + hexo.extend.filter.register('after_post_render', data => { const { config } = hexo; const theme = hexo.theme.config; @@ -10,14 +12,13 @@ hexo.extend.filter.register('after_post_render', data => { data.content = data.content.replace(/(]*) src=/img, '$1 data-src='); } if (theme.exturl) { - const url = require('url'); - const siteHost = url.parse(config.url).hostname || config.url; + const siteHost = parse(config.url).hostname || config.url; data.content = data.content.replace(/]* href="([^"]+)"[^>]*>([^<]+)<\/a>/img, (match, href, html) => { // Exit if the href attribute doesn't exists. if (!href) return match; // Exit if the url has same host with `config.url`, which means it's an internal link. - const link = url.parse(href); + const link = parse(href); if (!link.protocol || link.hostname === siteHost) return match; return `${html}`; diff --git a/scripts/helpers/next-config.js b/scripts/helpers/next-config.js index 5fe3a36..cef8bea 100644 --- a/scripts/helpers/next-config.js +++ b/scripts/helpers/next-config.js @@ -2,7 +2,7 @@ 'use strict'; -const url = require('url'); +const { parse } = require('url'); /** * Export theme config to js @@ -11,7 +11,7 @@ hexo.extend.helper.register('next_config', function() { const { config, theme, next_version } = this; config.algolia = config.algolia || {}; const exportConfig = { - hostname : url.parse(config.url).hostname || config.url, + hostname : parse(config.url).hostname || config.url, root : config.root, scheme : theme.scheme, version : next_version, diff --git a/scripts/helpers/next-url.js b/scripts/helpers/next-url.js index de12fe0..7212b44 100644 --- a/scripts/helpers/next-url.js +++ b/scripts/helpers/next-url.js @@ -3,12 +3,12 @@ 'use strict'; const { htmlTag } = require('hexo-util'); -const url = require('url'); +const { parse } = require('url'); hexo.extend.helper.register('next_url', function(path, text, options = {}) { const { config } = this; - const data = url.parse(path); - const siteHost = url.parse(config.url).hostname || config.url; + const data = parse(path); + const siteHost = parse(config.url).hostname || config.url; const theme = hexo.theme.config; let exturl = ''; diff --git a/source/js/schemes/muse.js b/source/js/schemes/muse.js index 2e9dec7..14f811e 100644 --- a/source/js/schemes/muse.js +++ b/source/js/schemes/muse.js @@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', () => { mouseupHandler: function(event) { const deltaX = event.pageX - mousePos.X; const deltaY = event.pageY - mousePos.Y; - const clickingBlankPart = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)) < 20 && event.target.matches('.main'); + const clickingBlankPart = Math.hypot(deltaX, deltaY) < 20 && event.target.matches('.main'); // Fancybox has z-index property, but medium-zoom does not, so the sidebar will overlay the zoomed image. if (clickingBlankPart || event.target.matches('img.medium-zoom-image')) { this.hideSidebar();