Ghost/core/server/utils/social-urls.js
Hannah Wolfe e96b60b850 Add helpers for facebook & twitter urls
refs #6534

- this PR assumes that we are now saving usernames only in the database for twitter & facebook
- adds a new social links utility which can generate twitter & facebook urls from the username
- adds a {{twitter_url}} and {{facebook_url}} helper which uses these
- adds a full suite of tests for the helpers & utils
2016-05-17 16:39:58 +01:00

10 lines
393 B
JavaScript

module.exports.twitterUrl = function twitterUrl(username) {
// Creates the canonical twitter URL without the '@'
return 'https://twitter.com/' + username.replace(/^@/, '');
};
module.exports.facebookUrl = function facebookUrl(username) {
// Handles a starting slash, this shouldn't happen, but just in case
return 'https://www.facebook.com/' + username.replace(/^\//, '');
};