Skip to content

Commit

Permalink
修改src并重新build
Browse files Browse the repository at this point in the history
PR #15
  • Loading branch information
mmdjiji committed Mar 10, 2021
1 parent ed41b00 commit faf0e5e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
30 changes: 20 additions & 10 deletions lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(locals) {
var _config$bangumi;

var config, root, wantWatch, watching, watched, _JSON$parse, __, contents;
var config, root, wantWatch, watching, watched, _JSON$parse, wantWatchExtra, watchingExtra, watchedExtra, _JSON$parse2, __, contents;

return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
Expand Down Expand Up @@ -57,22 +57,32 @@ module.exports = /*#__PURE__*/function () {
wantWatch = _JSON$parse.wantWatch;
watching = _JSON$parse.watching;
watched = _JSON$parse.watched;

// extra bangumis
console.log(path.join(this.source_dir, '/_data/extra_bangumis.json'));
if(fs.existsSync(path.join(this.source_dir, '/_data/extra_bangumis.json'))) {

if (fs.existsSync(path.join(this.source_dir, '/_data/extra_bangumis.json'))) {
log.info('Found extra bangumi data');
_JSON$parse = JSON.parse(fs.readFileSync(path.join(this.source_dir, '/_data/extra_bangumis.json')));
if(_JSON$parse.wantWatch) {
wantWatch = wantWatch.concat(_JSON$parse.wantWatch);
wantWatchExtra = [];
watchingExtra = [];
watchedExtra = [];
_JSON$parse2 = JSON.parse(fs.readFileSync(path.join(this.source_dir, '/_data/extra_bangumis.json')));
wantWatchExtra = _JSON$parse2.wantWatchExtra;
watchingExtra = _JSON$parse2.watchingExtra;
watchedExtra = _JSON$parse2.watchedExtra;

if (wantWatchExtra) {
wantWatch = wantWatch.concat(wantWatchExtra);
}
if(_JSON$parse.watching) {
watching = watching.concat(_JSON$parse.watching);

if (watchingExtra) {
watching = watching.concat(watchingExtra);
}
if(_JSON$parse.watched) {
watched = watched.concat(_JSON$parse.watched);

if (watchedExtra) {
watched = watched.concat(watchedExtra);
}
}

log.info(wantWatch.length + watching.length + watched.length + ' bangumis have been loaded');
}

Expand Down
20 changes: 19 additions & 1 deletion src/lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,30 @@ module.exports = async function (locals) {
if (root.endsWith('/')) {
root = root.slice(0, root.length - 1)
}
let wantWatch = []; let watching = []; let watched = []
let wantWatch = []; let watching = []; let watched = [];
console.log(path.join(this.source_dir, '/_data/bangumis.json'))
if (!fs.existsSync(path.join(this.source_dir, '/_data/bangumis.json'))) {
log.info('Can\'t find bilibili bangumi data, please use \'hexo bangumi -u\' command to get data')
} else {
({ wantWatch, watching, watched } = JSON.parse(fs.readFileSync(path.join(this.source_dir, '/_data/bangumis.json'))))

// extra bangumis
console.log(path.join(this.source_dir, '/_data/extra_bangumis.json'))
if(fs.existsSync(path.join(this.source_dir, '/_data/extra_bangumis.json'))) {
log.info('Found extra bangumi data');
let wantWatchExtra = []; let watchingExtra = []; let watchedExtra = [];
({ wantWatchExtra, watchingExtra, watchedExtra } = JSON.parse(fs.readFileSync(path.join(this.source_dir, '/_data/extra_bangumis.json'))))
if(wantWatchExtra) {
wantWatch = wantWatch.concat(wantWatchExtra)
}
if(watchingExtra) {
watching = watching.concat(watchingExtra)
}
if(watchedExtra) {
watched = watched.concat(watchedExtra)
}
}

log.info(wantWatch.length + watching.length + watched.length + ' bangumis have been loaded')
}

Expand Down

0 comments on commit faf0e5e

Please sign in to comment.