Skip to content

Commit

Permalink
refactor: simplify assignIn
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Oct 27, 2019
1 parent d0d45dc commit 7928973
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/theme/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ const { dirname, extname, join } = require('path');
const yfm = require('hexo-front-matter');
const Promise = require('bluebird');

const assignIn = (target, ...sources) => {
let source = [];
sources.forEach(src => {
source.push(...[src, Object.getPrototypeOf(src)]);
});
return Object.assign(target, ...source);
};

function View(path, data) {
this.path = path;
this.source = join(this._theme.base, 'layout', path);
Expand Down Expand Up @@ -70,7 +62,8 @@ View.prototype._buildLocals = function(locals) {
const data = Object.assign({}, this.data);
delete data.layout;
delete data._concat;
return assignIn({}, locals, data, {

return Object.assign({}, locals, Object.getPrototypeOf(locals), data, {
filename: this.source
});
};
Expand Down

0 comments on commit 7928973

Please sign in to comment.