vue-socials
Version:
Social media share buttons and counts for Vue.js
72 lines (61 loc) • 1.98 kB
JavaScript
import { defineComponent } from 'vue';
import BaseSocials from '../../mixins/BaseSocial/BaseSocial.js';
/**
* Hey!
*
* SGithubGist component used for Github Gists social network
* @link https://gist.github.com/
* @example https://gist.github.com/ai/e3683b03ba936ade91d33dbc721cd6d8/stargazers
*/
var GITHUB_LINK_TYPES = {
gist: 'gist',
star: 'star',
fork: 'fork',
download: 'download'
};
var SGithubGist = /* #__PURE__ */defineComponent({
name: 'SGithubGist',
mixins: [BaseSocials('GitHub Gists', {
width: 900,
height: 600
})],
computed: {
networkURL: function networkURL() {
var BASE_URL = 'https://gist.github.com/';
var shareOptions = this.shareOptions;
var username = shareOptions.username,
gistId = shareOptions.gistId,
type = shareOptions.type;
switch (type) {
case GITHUB_LINK_TYPES.fork:
return "".concat(BASE_URL).concat(username, "/").concat(gistId, "/forks");
case GITHUB_LINK_TYPES.star:
return "".concat(BASE_URL).concat(username, "/").concat(gistId, "/stargazers");
case GITHUB_LINK_TYPES.download:
return "".concat(BASE_URL).concat(username, "/").concat(gistId, "/archive/master.zip");
case GITHUB_LINK_TYPES.gist:
default:
return "".concat(BASE_URL).concat(username, "/").concat(gistId);
}
},
ariaLabel: function ariaLabel() {
var shareOptions = this.shareOptions;
var type = shareOptions.type;
switch (type) {
case GITHUB_LINK_TYPES.fork:
return 'Fork this gist.';
case GITHUB_LINK_TYPES.star:
return 'Star this gist.';
case GITHUB_LINK_TYPES.download:
return 'Download this gist.';
case GITHUB_LINK_TYPES.gist:
default:
return 'Watch this gist.';
}
}
},
render: function render() {
return this.generateComponent(this.networkURL);
}
});
export default SGithubGist;