Support tweets in metadata not having to be a list

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-03-05 19:41:32 -08:00
parent 13c149c9e0
commit 810c43185b

View File

@ -7,7 +7,7 @@ const File = require('./file');
const actions = require('./actions'); const actions = require('./actions');
const { URL } = require('url'); const { URL } = require('url');
const { resolve, readFile, isCleanUrl, ENGINE } = require('./resolve'); const { resolve, readFile, isCleanUrl, ENGINE } = require('./resolve');
const { isObject } = require('./lib/util'); const { isObject, isString } = require('./lib/util');
const pkg = require(resolve('package.json')); const pkg = require(resolve('package.json'));
const frontmatter = require('front-matter'); const frontmatter = require('front-matter');
@ -96,6 +96,7 @@ module.exports = exports = class Page extends File {
this.ignore = this.meta.ignore; this.ignore = this.meta.ignore;
this.images = webready; this.images = webready;
this.titlecard = titlecard; this.titlecard = titlecard;
if (this.meta.tweets && isString(this.meta.tweets)) this.meta.tweets = this.meta.tweets.split(/\s/);
this.tweets = (this.meta.tweets || []).map(parseTweetId); this.tweets = (this.meta.tweets || []).map(parseTweetId);
this.classes = Array.from(new Set(this.meta.classes || [])); this.classes = Array.from(new Set(this.meta.classes || []));