From 778187be9826849e277d0dfff3631041b31658d9 Mon Sep 17 00:00:00 2001 From: HCLonely Date: Wed, 10 Aug 2022 12:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dnexmoe=E4=B8=BB=E9=A2=98(#166?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bangumi-generator.js | 16 ++++++++++------ package.json | 2 +- src/lib/bangumi-generator.js | 7 +++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/bangumi-generator.js b/lib/bangumi-generator.js index a0af65a..281ee02 100644 --- a/lib/bangumi-generator.js +++ b/lib/bangumi-generator.js @@ -34,6 +34,7 @@ module.exports = /*#__PURE__*/function () { var type, config, + full_url_for, root, wantWatch, watching, @@ -63,6 +64,8 @@ module.exports = /*#__PURE__*/function () { return _context.abrupt("return"); case 4: + // eslint-disable-next-line camelcase + full_url_for = this.extend.helper.get('full_url_for').bind(this); root = config.root; if (root.endsWith('/')) { @@ -116,7 +119,7 @@ module.exports = /*#__PURE__*/function () { __ = i18n.__(config.language); - _context.next = 13; + _context.next = 14; return ejs.renderFile(path.join(__dirname, 'templates/bangumi.ejs'), { quote: config[type].quote, show: config[type].show || 1, @@ -138,19 +141,20 @@ module.exports = /*#__PURE__*/function () { async: false }); - case 13: + case 14: contents = _context.sent; - customPath = config[type].path; + customPath = config[type].path || "".concat(type, "s/index.html"); return _context.abrupt("return", { - path: customPath || "".concat(type, "s/index.html"), + path: customPath, data: _objectSpread({ title: config[type].title, - content: contents + content: contents, + permalink: full_url_for(customPath) }, config === null || config === void 0 ? void 0 : (_config$type2 = config[type]) === null || _config$type2 === void 0 ? void 0 : _config$type2.extra_options), layout: ['page', 'post'] }); - case 16: + case 17: case "end": return _context.stop(); } diff --git a/package.json b/package.json index 8ede666..f19c5c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-bilibili-bangumi", - "version": "1.8.0", + "version": "1.8.1", "description": "hexo bilibili番剧页", "main": "index.js", "scripts": { diff --git a/src/lib/bangumi-generator.js b/src/lib/bangumi-generator.js index 5d3f62e..78738d7 100644 --- a/src/lib/bangumi-generator.js +++ b/src/lib/bangumi-generator.js @@ -14,6 +14,8 @@ module.exports = async function (locals, type = 'bangumi') { if (!config?.[type]?.enable) { return; } + // eslint-disable-next-line camelcase + const full_url_for = this.extend.helper.get('full_url_for').bind(this); let { root } = config; if (root.endsWith('/')) { @@ -80,12 +82,13 @@ module.exports = async function (locals, type = 'bangumi') { root }, { async: false }); - const customPath = config[type].path; + const customPath = config[type].path || (`${type}s/index.html`); return { - path: customPath || (`${type}s/index.html`), + path: customPath, data: { title: config[type].title, content: contents, + permalink: full_url_for(customPath), ...config?.[type]?.extra_options }, layout: ['page', 'post']