Skip to content

Commit

Permalink
修复使用bangumi源时套用bili模板;优化Pjax兼容性(#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jun 13, 2023
1 parent 7cf5672 commit 5926ee8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module.exports = /*#__PURE__*/function () {
showMyComment: (_config$type$showMyCo = config[type].showMyComment) !== null && _config$type$showMyCo !== void 0 ? _config$type$showMyCo : false,
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 === 'bgm' ? 'bgm' : 'bili', "-template.ejs"))).toString().replace('class="bangumi-item"', 'class="bangumi-item bangumi-hide"'),
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,
Expand Down
14 changes: 8 additions & 6 deletions lib/templates/bangumi.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,45 @@
<div id="bangumi-item1">
<% if (pagination) { %>
<% wantWatch.slice(0, 10).forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } else { %>
<% wantWatch.forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } %>
</div>
<div id="bangumi-item2">
<% if (pagination) { %>
<% watching.slice(0, 10).forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } else { %>
<% watching.forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } %>
</div>
<div id="bangumi-item3">
<% if (pagination) { %>
<% watched.slice(0, 10).forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } else { %>
<% watched.forEach(function(item){ %>
<%- include((source === 'bgm' ? 'bgm' : 'bili') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<%- include((source === 'bili' ? 'bili' : 'bgm') + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %>
<% }); %>
<%- include('pagination.ejs', {__: __}) %>
<% } %>
</div>
</div>
<script>
(function () {
<% if (pagination) { %>
const ejsTemplate = '<%- ejsTemplate.replace(/\n/g, '') %>';
const loading = '<%- loading %>';
Expand All @@ -80,4 +81,5 @@
<%- include('index.js') %>
document.getElementsByClassName('bangumi-tab')[<%- show %>].click();
<%- include('pagination.js', {__: __}) %>
})();
</script>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-bilibili-bangumi",
"version": "1.8.7",
"version": "1.8.8",
"description": "hexo bilibili番剧页",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = async function (locals, type = 'bangumi') {
showMyComment: config[type].showMyComment ?? false,
pagination: config[type].pagination ?? false,
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 === 'bgm' ? 'bgm' : 'bili'}-template.ejs`)).toString()
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,
Expand Down

0 comments on commit 5926ee8

Please sign in to comment.