diff --git a/README.md b/README.md index be2b402..67c65e5 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ bangumi: # 追番设置 webp: progress: extraOrder: + order: latest proxy: host: '代理host' port: '代理端口' @@ -62,6 +63,7 @@ cinema: # 追剧设置 webp: progress: extraOrder: + order: extra_options: key: value ``` @@ -88,6 +90,7 @@ cinema: # 追剧设置 - **extraOrder**: 手动添加的番剧/追剧数据是否优先显示,`1`为优先,其它为不优先 - **showMyComment**: 使用`bgm`源时显示自己的评价及评论,默认`false` - **pagination**: 分页优化,只将第一页的数据渲染到`html`文件中,其余数据将通过异步请求加载,避免番剧过多时html文件过大导致页面加载缓慢,建议番剧较多时使用,默认`false` +- **order**: 排序,支持`latest`(默认,按添加时间排序), `score`(评分升序), `-score`(评分降序) - **extra_options**: 此配置会扩展到Hexo`page`变量中 ## 使用 diff --git a/lib/bangumi-generator.js b/lib/bangumi-generator.js index 885b59b..db59f3f 100644 --- a/lib/bangumi-generator.js +++ b/lib/bangumi-generator.js @@ -113,9 +113,15 @@ module.exports = /*#__PURE__*/function () { pagination: (_config$type$paginati = config[type].pagination) !== null && _config$type$paginati !== void 0 ? _config$type$paginati : false, theme: fs.existsSync(path.join(__dirname, "templates/theme/".concat(config.theme, ".min.css"))) ? config.theme : null, ejsTemplate: fs.readFileSync(path.join(__dirname, "templates/".concat(config[type].source === 'bili' ? 'bili' : 'bgm', "-template.ejs"))).toString().replace('class="bangumi-item"', 'class="bangumi-item bangumi-hide"'), - wantWatch: wantWatch, - watched: watched, - watching: watching, + wantWatch: ['score', '-score'].includes(config[type].order) ? wantWatch.sort(function (a, b) { + return config[type].order === 'score' ? a.score - b.score : b.score - a.score; + }) : wantWatch, + watched: ['score', '-score'].includes(config[type].order) ? watched.sort(function (a, b) { + return config[type].order === 'score' ? a.score - b.score : b.score - a.score; + }) : watched, + watching: ['score', '-score'].includes(config[type].order) ? watching.sort(function (a, b) { + return config[type].order === 'score' ? a.score - b.score : b.score - a.score; + }) : watching, type: type, __: __, root: root diff --git a/package.json b/package.json index 42ba0d5..d600e70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-bilibili-bangumi", - "version": "1.8.8", + "version": "1.8.9", "description": "hexo bilibili番剧页", "main": "index.js", "scripts": { diff --git a/src/lib/bangumi-generator.js b/src/lib/bangumi-generator.js index 1311aaa..3e7afb1 100644 --- a/src/lib/bangumi-generator.js +++ b/src/lib/bangumi-generator.js @@ -81,9 +81,9 @@ module.exports = async function (locals, type = 'bangumi') { theme: fs.existsSync(path.join(__dirname, `templates/theme/${config.theme}.min.css`)) ? config.theme : null, ejsTemplate: fs.readFileSync(path.join(__dirname, `templates/${config[type].source === 'bili' ? 'bili' : 'bgm'}-template.ejs`)).toString() .replace('class="bangumi-item"', 'class="bangumi-item bangumi-hide"'), - wantWatch, - watched, - watching, + wantWatch: ['score', '-score'].includes(config[type].order) ? wantWatch.sort((a, b) => (config[type].order === 'score' ? (a.score - b.score) : (b.score - a.score))) : wantWatch, + watched: ['score', '-score'].includes(config[type].order) ? watched.sort((a, b) => (config[type].order === 'score' ? (a.score - b.score) : (b.score - a.score))) : watched, + watching: ['score', '-score'].includes(config[type].order) ? watching.sort((a, b) => (config[type].order === 'score' ? (a.score - b.score) : (b.score - a.score))) : watching, type, __, root