vue-socials
Version:
Social media share buttons and counts for Vue.js
57 lines (48 loc) • 1.31 kB
JavaScript
import { defineComponent } from 'vue';
import JSONP from '../../utils/jsonp.js';
import BaseCount from '../../mixins/BaseCount/BaseCount.js';
/**
* Hey!
*
* SGithubCount component used for GitHub social network
* @link https://github.com/
*/
var GITHUB_LINK_TYPES = {
follow: 'follow'
};
var SGithubCount = /* #__PURE__ */defineComponent({
name: 'SGithubCount',
mixins: [BaseCount('GitHub', {}, true, '@c followers on @s.')],
methods: {
handleGithubResponse: function handleGithubResponse(data) {
this.handleResult(data);
if ('followers' in data.data) {
this.handleCount(data.data.followers);
}
}
},
mounted: function mounted() {
var _this = this;
var shareOptions = this.shareOptions;
var username = shareOptions.username,
type = shareOptions.type;
var BASE_URL = 'https://api.github.com/';
var finalURL;
switch (type) {
case GITHUB_LINK_TYPES.follow:
default:
finalURL = "".concat(BASE_URL, "users/").concat(username);
}
this.handleLoading(true);
JSONP(finalURL, function (err, data) {
_this.handleLoading(false);
if (data) {
_this.handleGithubResponse(data);
}
if (err) {
_this.handleError(err);
}
});
}
});
export default SGithubCount;