From 27d313ba7aa904958e70a6f2951d73ef7668a6b2 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 24 Nov 2022 23:19:37 +0800 Subject: [PATCH 1/4] use top-level import --- lib/extend/index.js | 24 ++++++++++++++---------- lib/models/index.js | 24 ++++++++++++++---------- lib/plugins/console/list/index.js | 11 ++++++----- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lib/extend/index.js b/lib/extend/index.js index 5e4eb37b28..fded0037cf 100644 --- a/lib/extend/index.js +++ b/lib/extend/index.js @@ -1,12 +1,16 @@ 'use strict'; -exports.Console = require('./console'); -exports.Deployer = require('./deployer'); -exports.Filter = require('./filter'); -exports.Generator = require('./generator'); -exports.Helper = require('./helper'); -exports.Injector = require('./injector'); -exports.Migrator = require('./migrator'); -exports.Processor = require('./processor'); -exports.Renderer = require('./renderer'); -exports.Tag = require('./tag'); +const Console = require('./console'); +const Deployer = require('./deployer'); +const Filter = require('./filter'); +const Generator = require('./generator'); +const Helper = require('./helper'); +const Injector = require('./injector'); +const Migrator = require('./migrator'); +const Processor = require('./processor'); +const Renderer = require('./renderer'); +const Tag = require('./tag'); + +module.exports = { + Console, Deployer, Filter, Generator, Helper, Injector, Migrator, Processor, Renderer, Tag +}; diff --git a/lib/models/index.js b/lib/models/index.js index f52d915e1b..18ae185867 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -1,12 +1,16 @@ 'use strict'; -exports.Asset = require('./asset'); -exports.Cache = require('./cache'); -exports.Category = require('./category'); -exports.Data = require('./data'); -exports.Page = require('./page'); -exports.Post = require('./post'); -exports.PostAsset = require('./post_asset'); -exports.PostCategory = require('./post_category'); -exports.PostTag = require('./post_tag'); -exports.Tag = require('./tag'); +const Asset = require('./asset'); +const Cache = require('./cache'); +const Category = require('./category'); +const Data = require('./data'); +const Page = require('./page'); +const Post = require('./post'); +const PostAsset = require('./post_asset'); +const PostCategory = require('./post_category'); +const PostTag = require('./post_tag'); +const Tag = require('./tag'); + +module.exports = { + Asset, Cache, Category, Data, Page, Post, PostAsset, PostCategory, PostTag, Tag +}; diff --git a/lib/plugins/console/list/index.js b/lib/plugins/console/list/index.js index 4ab6fba1d0..debab88983 100644 --- a/lib/plugins/console/list/index.js +++ b/lib/plugins/console/list/index.js @@ -1,13 +1,14 @@ 'use strict'; const abbrev = require('abbrev'); +const page = require('./page'); +const post = require('./post'); +const route = require('./route'); +const tag = require('./tag'); +const category = require('./category'); const store = { - page: require('./page'), - post: require('./post'), - route: require('./route'), - tag: require('./tag'), - category: require('./category') + page, post, route, tag, category }; const alias = abbrev(Object.keys(store)); From 9f99dd2c324efd87c259ce08d7ab1e821cef738b Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Thu, 24 Nov 2022 23:22:27 +0800 Subject: [PATCH 2/4] bug fix --- lib/hexo/scaffold.js | 2 +- lib/plugins/console/generate.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hexo/scaffold.js b/lib/hexo/scaffold.js index f1e83c0cf1..c1d59f2aa2 100644 --- a/lib/hexo/scaffold.js +++ b/lib/hexo/scaffold.js @@ -26,7 +26,7 @@ class Scaffold { if (!exist) return []; return listDir(scaffoldDir, { - ignoreFilesRegex: /^_|\/_/ + ignorePattern: /^_|\/_/ }); }).map(item => ({ name: item.substring(0, item.length - extname(item).length), diff --git a/lib/plugins/console/generate.js b/lib/plugins/console/generate.js index a95abb0e15..261ba40132 100644 --- a/lib/plugins/console/generate.js +++ b/lib/plugins/console/generate.js @@ -133,7 +133,7 @@ class Generater { // Check the public folder return stat(publicDir).then(stats => { if (!stats.isDirectory()) { - throw new Error('%s is not a directory', magenta(tildify(publicDir))); + throw new Error(`${magenta(tildify(publicDir))} is not a directory`); } }).catch(err => { // Create public folder if not exists From 2b1f800c098b6b8491c6512e7ef674d8a6b72c68 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 25 Nov 2022 11:46:58 +0800 Subject: [PATCH 3/4] number_format --- lib/plugins/helper/number_format.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/helper/number_format.js b/lib/plugins/helper/number_format.js index 7a1495f67f..c6c2c0985d 100644 --- a/lib/plugins/helper/number_format.js +++ b/lib/plugins/helper/number_format.js @@ -30,7 +30,7 @@ function numberFormatHelper(num, options = {}) { const afterLast = after[precision]; const last = parseInt(after[precision - 1], 10); - afterResult = after.substring(0, precision - 1) + (afterLast < 5 ? last : last + 1); + afterResult = after.substring(0, precision - 1) + (Number(afterLast) < 5 ? last : last + 1); } else { afterResult = after; for (let i = 0, len = precision - afterLength; i < len; i++) { @@ -39,7 +39,7 @@ function numberFormatHelper(num, options = {}) { } after = afterResult; - } else if (precision === 0 || precision === '0') { + } else if (precision === 0) { after = ''; } From 315ddcd5435d2b4deee79525df6f7916686bc498 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 25 Nov 2022 11:51:53 +0800 Subject: [PATCH 4/4] imgTag --- lib/plugins/tag/img.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/tag/img.js b/lib/plugins/tag/img.js index 5b913beeda..a98737254f 100644 --- a/lib/plugins/tag/img.js +++ b/lib/plugins/tag/img.js @@ -13,7 +13,7 @@ const rMeta = /["']?([^"']+)?["']?\s*["']?([^"']+)?["']?/; */ module.exports = ctx => { - return function imgTag(args, content) { + return function imgTag(args) { const classes = []; let src, width, height, title, alt;