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
|
2021-09-28 17:06:33 +03:00
|
|
|
const {socialUrls} = require('../services/proxy');
|
2022-04-05 19:38:46 +03:00
|
|
|
const {localUtils} = require('../services/handlebars');
|
2016-05-17 16:06:12 +03:00
|
|
|
|
2017-11-01 16:44:54 +03:00
|
|
|
// We use the name twitter_url to match the helper for consistency:
|
|
|
|
module.exports = function twitter_url(username, options) { // eslint-disable-line camelcase
|
2016-05-17 16:06:12 +03:00
|
|
|
if (!options) {
|
|
|
|
options = username;
|
2019-09-10 12:37:04 +03:00
|
|
|
username = localUtils.findKey('twitter', this, options.data.site);
|
2016-05-17 16:06:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (username) {
|
2017-12-15 00:22:37 +03:00
|
|
|
return socialUrls.twitter(username);
|
2016-05-17 16:06:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|