summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-sharing/src/SITES.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-plugin-sharing/src/SITES.js')
-rw-r--r--packages/gitbook-plugin-sharing/src/SITES.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/packages/gitbook-plugin-sharing/src/SITES.js b/packages/gitbook-plugin-sharing/src/SITES.js
new file mode 100644
index 0000000..86eae74
--- /dev/null
+++ b/packages/gitbook-plugin-sharing/src/SITES.js
@@ -0,0 +1,72 @@
+// All the sharing platforms
+const SITES = {
+
+ // One sharing platform
+ 'facebook': {
+ // Displayed name
+ label: 'Facebook',
+
+ // Font-awesome icon id
+ icon: 'facebook',
+
+ /**
+ * Share a page on this platform
+ * @param {String} url The url to share
+ * @param {String} title The title of the url page
+ */
+ onShare(url, title) {
+ url = encodeURIComponent(url);
+ window.open(`http://www.facebook.com/sharer/sharer.php?s=100&p[url]=${url}`);
+ }
+ },
+
+ 'twitter': {
+ label: 'Twitter',
+ icon: 'twitter',
+ onShare(url, title) {
+ const status = encodeURIComponent(title + ' ' + url);
+ window.open(`http://twitter.com/home?status=${status}`);
+ }
+ },
+
+ 'google': {
+ label: 'Google+',
+ icon: 'google-plus',
+ onShare(url, title) {
+ url = encodeURIComponent(url);
+ window.open(`https://plus.google.com/share?url=${url}`);
+ }
+ },
+
+ 'weibo': {
+ label: 'Weibo',
+ icon: 'weibo',
+ onShare(url, title) {
+ url = encodeURIComponent(url);
+ title = encodeURIComponent(title);
+ window.open(`http://service.weibo.com/share/share.php?content=utf-8&url=${url}&title=${title}`);
+ }
+ },
+
+ 'instapaper': {
+ label: 'Instapaper',
+ icon: 'instapaper',
+ onShare(url, title) {
+ url = encodeURIComponent(url);
+ window.open(`http://www.instapaper.com/text?u=${url}`);
+ }
+ },
+
+ 'vk': {
+ label: 'VK',
+ icon: 'vk',
+ onShare(url, title) {
+ url = encodeURIComponent(url);
+ window.open(`http://vkontakte.ru/share.php?url=${url}`);
+ }
+ }
+};
+
+SITES.ALL = Object.keys(SITES);
+
+module.exports = SITES;