Skip to content

Instantly share code, notes, and snippets.

@nyawach
Created September 18, 2017 12:14
Show Gist options
  • Save nyawach/03ad85008e068f929420a2d34784b066 to your computer and use it in GitHub Desktop.
Save nyawach/03ad85008e068f929420a2d34784b066 to your computer and use it in GitHub Desktop.
ツイートシェア周りをJSで動的に設定する時につかえるやーつ
import qs from 'querystring';
export const createTwitterIntent = function (opts = {}) {
return 'http://twitter.com/share?' + qs.stringify(opts);
};
export const createFacebookIntent = function (url) {
return 'http://www.facebook.com/share.php?' + qs.stringify({
u: url
});
};
export const createLineIntent = function (opts = {}) {
return 'http://line.me/R/msg/text?' + [
encodeURIComponent(opts.text || ''),
encodeURIComponent(opts.url || '')
].join(' ');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment