diff --git a/_includes/gitbook-sharing.json.tpl b/_includes/gitbook-sharing.json.tpl index f571e15031..42e3d87144 100644 --- a/_includes/gitbook-sharing.json.tpl +++ b/_includes/gitbook-sharing.json.tpl @@ -1,13 +1,28 @@ "sharing": { - "all": ["facebook", "google", "twitter", "weibo", "instapaper", "github", "telegram"], "facebook": true, + "google": false, + "github": true, + {% if site.github_username %} + "github_link": "https://github.com/{{ site.github_username }}", + {% else %} "github_link": "https://github.com", + {% endif %} + "telegram": false, "telegram_link": "https://t.me", + "instapaper": false, + "twitter": true, + {% if site.twitter_username %} + "twitter_link": "https://twitter.com/{{ site.twitter_username }}", + {% endif %} + "vk": false, - "weibo": false + + "weibo": false, + + "all": ["facebook", "google", "twitter", "weibo", "instapaper", "github", "telegram"] }, diff --git a/assets/gitbook/gitbook-plugin-sharing/buttons.js b/assets/gitbook/gitbook-plugin-sharing/buttons.js index c8f819b1ff..654aa0567d 100644 --- a/assets/gitbook/gitbook-plugin-sharing/buttons.js +++ b/assets/gitbook/gitbook-plugin-sharing/buttons.js @@ -96,17 +96,13 @@ require(['gitbook', 'jquery'], function(gitbook, $) { if (!opts[sideId]) return; var onClick = site.onClick; - - if (sideId === "github" && opts["github_link"] !== undefined && opts["github_link"] !== "") { - onClick = function(e) { - e.preventDefault(); - window.open(opts["github_link"]); - } - } - if (sideId === "telegram" && opts["telegram_link"] !== undefined && opts["telegram_link"] !== "") { + + // override target link with provided link + var side_link = opts[`${sideId}_link`] + if (side_link !== undefined && side_link !== "") { onClick = function(e) { e.preventDefault(); - window.open(opts["telegram_link"]); + window.open(side_link); } }