af4bfb8862
- purely for cleanliness! - we use kebabcase by default - tests should be kebab-case-file_spec.js (one day we want this to be .test.js)
17 lines
618 B
JavaScript
17 lines
618 B
JavaScript
const getContextObject = require('./context-object.js');
|
|
const _ = require('lodash');
|
|
|
|
function getAuthorFacebookUrl(data) {
|
|
const context = data.context ? data.context : null;
|
|
const contextObject = getContextObject(data, context);
|
|
|
|
if ((_.includes(context, 'post') || _.includes(context, 'page')) && contextObject.primary_author && contextObject.primary_author.facebook) {
|
|
return contextObject.primary_author.facebook;
|
|
} else if (_.includes(context, 'author') && contextObject.facebook) {
|
|
return contextObject.facebook;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
module.exports = getAuthorFacebookUrl;
|