2016-05-17 16:06:12 +03:00
|
|
|
// # Twitter URL Helper
|
|
|
|
// Usage: `{{twitter_url}}` or `{{twitter_url author.twitter}}`
|
|
|
|
//
|
|
|
|
// Output a url for a twitter username
|
|
|
|
//
|
|
|
|
// We use the name twitter_url to match the helper for consistency:
|
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
var proxy = require('./proxy'),
|
|
|
|
socialUrls = proxy.socialUrls,
|
|
|
|
findKey = proxy.utils.findKey;
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
module.exports = function twitter_url(username, options) {
|
2016-05-17 16:06:12 +03:00
|
|
|
if (!options) {
|
|
|
|
options = username;
|
|
|
|
username = findKey('twitter', this, options.data.blog);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (username) {
|
|
|
|
return socialUrls.twitterUrl(username);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|