Skip to content

Commit

Permalink
修复部分浏览器排版错误的bug,添加自定义字体颜色配置项(#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
HCLonely committed Jun 25, 2020
1 parent bad639f commit 362a825
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ $ npm install hexo-bilibili-bangumi --save

``` yaml
bangumi:
enable: true
path:
vmid:
enable: true
path:
vmid:
title: '追番列表'
quote: '生命不息,追番不止!'
show: 1
loading:
loading:
metaColor:
color:
```
- **enable**: 是否启用
Expand All @@ -38,6 +40,8 @@ bangumi:
- **quote**: 写在页面开头的一段话,支持html语法
- **show**: 初始显示页面:`0: 想看`, `1: 在看`, `2: 看过`,默认为`1`
- **loading**: 图片加载完成前的loading图片
- **metaColor**: meta部分(简介上方)字体颜色
- **color**: 简介字体颜色

## 使用

Expand All @@ -56,4 +60,4 @@ bangumi:

## Lisense

[Apache Licence 2.0](https://github.com/HCLonely/hexo-bilibili-bangumi/blob/master/LICENSE)
[Apache Licence 2.0](https://github.com/HCLonely/hexo-bilibili-bangumi/blob/master/LICENSE)
2 changes: 2 additions & 0 deletions lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ module.exports = /*#__PURE__*/function () {
'quote': config.bangumi.quote,
'show': config.bangumi.show || 1,
'loading': config.bangumi.loading,
'metaColor': config.bangumi.metaColor ? "style=\"color:".concat(config.bangumi.metaColor, "\"") : "",
'color': config.bangumi.color ? "style=\"color:".concat(config.bangumi.color, "\"") : "",
'wantWatch': wantWatch,
'watched': watched,
'watching': watching,
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/templates/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a target="_blank" href="https://www.bilibili.com/bangumi/media/md<%= item.id %>/"><%= item.title || Unknown %></a>
</div>
<div class="bangumi-meta">
<span class="bangumi-info-items">
<span class="bangumi-info-items" <%- metaColor %>>
<span class="bangumi-info-item">
<% if(item.totalCount){ %>
<span class="bangumi-info-total"><%= item.totalCount %></span><em
Expand Down Expand Up @@ -35,6 +35,6 @@
</span>
</span>
</div>
<div class="bangumi-comments">简介:<%= item.des || "暂无简介" %> </div>
<div class="bangumi-comments" <%- color %>><br/>简介:<%= item.des || "暂无简介" %> </div>
</div>
</div>
</div>
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.3.0",
"version": "1.3.1",
"description": "hexo bilibili番剧页",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions src/lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = async function (locals) {
let config = this.config;
if (!config?.bangumi?.enable) {
return;
}
}

let root = config.root;
if (root.endsWith('/')) {
Expand All @@ -27,13 +27,15 @@ module.exports = async function (locals) {
({ wantWatch, watching, watched } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../data/bangumis.json'))));
log.info(wantWatch.length + watching.length + watched.length + ' bangumis have been loaded');
}

let __ = i18n.__(config.language);

let contents = ejs.renderFile(path.join(__dirname, 'templates/bangumi.ejs'), {
'quote': config.bangumi.quote,
'show': config.bangumi.show || 1,
'loading': config.bangumi.loading,
'metaColor': config.bangumi.metaColor ? `style="color:${config.bangumi.metaColor}"` : "",
'color': config.bangumi.color ? `style="color:${config.bangumi.color}"` : "",
'wantWatch': wantWatch,
'watched': watched,
'watching': watching,
Expand All @@ -44,7 +46,7 @@ module.exports = async function (locals) {
if (err) console.log(err);
return result;
});

return {
path: config.bangumi.path || 'bangumis/index.html',
data: {
Expand All @@ -53,4 +55,4 @@ module.exports = async function (locals) {
},
layout: ['page', 'post']
};
};
};
6 changes: 4 additions & 2 deletions src/lib/templates/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ a.bangumi-tab {
}

.bangumi-info-label-em {
color: #0000;
color: rgba(0, 0, 0, 0);
opacity:0;
visibility:hidden;
line-height: 6px !important;
padding: 0 !important;
}
Expand Down Expand Up @@ -174,4 +176,4 @@ a.bangumi-tab {
.bangumi-info-item {
width: 45%;
}
}
}

0 comments on commit 362a825

Please sign in to comment.