Webready unified into a getter

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-04-07 09:53:33 -07:00
parent e783e92029
commit eb2081ce9e
2 changed files with 6 additions and 3 deletions

View File

@ -113,11 +113,12 @@ module.exports = exports = class Asset extends File {
return this;
}
webready () {
const { type, name, sizes } = this;
get webready () {
const { type, name, url, sizes } = this;
return {
type,
name,
url,
sizes: sizes.map((s) => pick(s, [ 'url', 'width', 'height' ])),
};
}

View File

@ -25,7 +25,7 @@ module.exports = exports = class Files {
find(assets, { name: 'titlecard', dir: this.base }),
);
this._getWebReady = memoize(() => assets && keyBy(assets.map((a) => a.webready()), 'name'));
this._getWebReady = memoize(() => assets && keyBy(assets.map((a) => a.webready), 'name'));
this.for = memoize(this.for);
}
@ -63,8 +63,10 @@ module.exports = exports = class Files {
_parsePath (filepath) {
if (typeof filepath === 'object') return filepath;
if (filepath.includes('#')) return false;
const k = kind(filepath);
const F = this.KIND_MAP[k];
if (!F) return false;
const f = new F(filepath);
if (f.kind === KIND.PAGE && f.preprocessed) return false;
return f;