Skip to content

Commit

Permalink
Merge pull request sighingnow#89 from marc-portier/feature/social-sha…
Browse files Browse the repository at this point in the history
…re-support

Feature slightly enhanced social share support
  • Loading branch information
sighingnow authored Aug 8, 2023
2 parents 9bd8539 + 4befaf0 commit 99db37d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
19 changes: 17 additions & 2 deletions _includes/gitbook-sharing.json.tpl
Original file line number Diff line number Diff line change
@@ -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"]
},
14 changes: 5 additions & 9 deletions assets/gitbook/gitbook-plugin-sharing/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 99db37d

Please sign in to comment.