badges
Version:
The definitive collection of badges for rendering
729 lines (728 loc) • 30.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.quorafollow = exports.githubstar = exports.githubfollow = exports.twitterfollow = exports.twittertweet = exports.facebookfollow = exports.facebooklike = exports.hackernewssubmit = exports.redditsubmit = exports.googleplusone = exports.gabeacon = exports.twitch = exports.discord = exports.slackin = exports.slackinscript = exports.boostlab = exports.thanksapp = exports.liberapay = exports.buymeacoffee = exports.wishlist = exports.bitcoin = exports.crypto = exports.paypal = exports.flattr = exports.gratipay = exports.opencollective = exports.patreon = exports.thanksdev = exports.githubsponsors = exports.sixtydevstips = exports.githubworkflow = exports.waffle = exports.bithound = exports.codeclimate = exports.coveralls = exports.codeship = exports.travisci = exports.saucelabs = exports.saucelabsbm = exports.nodeico = exports.daviddmdev = exports.daviddm = exports.npmdownloads = exports.npmversion = exports.shields = exports.badge = void 0;
// Import
const querystring_1 = require("querystring");
// @ts-ignore
const env = typeof process !== 'undefined' ? process.env : {};
/** Generate a HTML badge */
function badge({ image, alt, url, title }) {
// Check
if (!image)
throw new Error('image is missing');
// Create
let result = alt
? `<img src="${image}" alt="${alt}" />`
: `<img src="${image}" />`;
if (url) {
result =
(title ? `<a href="${url}" title="${title}">` : `<a href="${url}">`) +
result +
'</a>';
}
return result;
}
exports.badge = badge;
badge.badgeCategory = 'custom';
/** Shields Custom Badge */
function shields({ left, right, color = 'yellow', alt, url, title, }) {
// Check
if (!left)
throw new Error('left is missing');
if (!right)
throw new Error('right is missing');
// Create
const image = `https://img.shields.io/badge/${left}-${right}-${color}.svg`;
return badge({ image, alt, url, title });
}
exports.shields = shields;
shields.badgeCategory = 'custom';
/** NPM Version Badge */
function npmversion({ npmPackageName }) {
// Check
if (!npmPackageName)
throw new Error('npmPackageName is missing');
// Create
const image = `https://img.shields.io/npm/v/${npmPackageName}.svg`;
const url = `https://npmjs.org/package/${npmPackageName}`;
const alt = 'NPM version';
const title = 'View this project on NPM';
return badge({ image, alt, url, title });
}
exports.npmversion = npmversion;
npmversion.badgeCategory = 'development';
/** NPM Downloads Badge */
function npmdownloads({ npmPackageName }) {
// Check
if (!npmPackageName)
throw new Error('npmPackageName is missing');
const image = `https://img.shields.io/npm/dm/${npmPackageName}.svg`;
const url = `https://npmjs.org/package/${npmPackageName}`;
const alt = 'NPM downloads';
const title = 'View this project on NPM';
return badge({ image, alt, url, title });
}
exports.npmdownloads = npmdownloads;
npmdownloads.badgeCategory = 'development';
/** David DM Dependencies Badge */
function daviddm({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://img.shields.io/david/${githubSlug}.svg`;
const url = `https://david-dm.org/${githubSlug}`;
const alt = 'Dependency Status';
const title = "View the status of this project's dependencies on DavidDM";
return badge({ image, alt, url, title });
}
exports.daviddm = daviddm;
daviddm.badgeCategory = 'development';
/** David DM Dev Dependencies Badge */
function daviddmdev({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://img.shields.io/david/dev/${githubSlug}.svg`;
const url = `https://david-dm.org/${githubSlug}#info=devDependencies`;
const alt = 'Dev Dependency Status';
const title = "View the status of this project's development dependencies on DavidDM";
return badge({ image, alt, url, title });
}
exports.daviddmdev = daviddmdev;
daviddmdev.badgeCategory = 'development';
/** Nodei.co Badge */
function nodeico({ npmPackageName, nodeicoQueryString, }) {
// Prepare
if (!npmPackageName)
throw new Error('npmPackageName is missing');
if (nodeicoQueryString &&
typeof nodeicoQueryString !== 'string' &&
typeof nodeicoQueryString !== 'object') {
throw new Error('nodeicoQueryString must be a string or an object');
}
// Return
const url = `https://www.npmjs.com/package/${npmPackageName}`;
const alt = 'Nodei.co badge';
const title = 'Nodei.co badge';
let image = `https://nodei.co/npm/${npmPackageName}.png`;
const query = typeof nodeicoQueryString === 'object'
? (0, querystring_1.stringify)(nodeicoQueryString)
: nodeicoQueryString;
if (query)
image += `?${query}`;
return badge({ image, alt, url, title });
}
exports.nodeico = nodeico;
nodeico.badgeCategory = 'development';
/** Sauce Labs Browser Matrix Badge */
function saucelabsbm({ saucelabsUsername, saucelabsAuthToken, }) {
// Check
if (!saucelabsUsername)
throw new Error('saucelabsUsername is missing');
saucelabsAuthToken = saucelabsAuthToken || env.SAUCELABS_AUTH_TOKEN;
if (!saucelabsAuthToken)
throw new Error('saucelabsAuthToken is missing');
// Create
const image = `https://saucelabs.com/browser-matrix/${saucelabsUsername}.svg?auth=${escape(saucelabsAuthToken)}`;
const url = `https://saucelabs.com/u/${saucelabsUsername}`;
const alt = 'Sauce Labs Browser Matrix';
const title = "Check this project's browser tests on Sauce Labs";
return badge({ image, alt, url, title });
}
exports.saucelabsbm = saucelabsbm;
saucelabsbm.badgeCategory = 'testing';
saucelabsbm.badgeInline = false;
/** Sauce Labs Badge */
function saucelabs({ saucelabsUsername, saucelabsAuthToken, }) {
// Check
if (!saucelabsUsername)
throw new Error('saucelabsUsername is missing');
saucelabsAuthToken = saucelabsAuthToken || env.SAUCELABS_AUTH_TOKEN;
if (!saucelabsAuthToken)
throw new Error('saucelabsAuthToken is missing');
// Create
const image = `https://saucelabs.com/browser-matrix/${saucelabsUsername}.svg?auth=${escape(saucelabsAuthToken)}`;
const url = `https://saucelabs.com/u/${saucelabsUsername}`;
const alt = 'Sauce Labs Browser Matrix';
const title = "Check this project's browser tests on Sauce Labs";
return badge({ image, alt, url, title });
}
exports.saucelabs = saucelabs;
saucelabs.badgeCategory = 'testing';
/** Travis CI Badge */
function travisci({ githubSlug, travisTLD = 'org', }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = [
'https://img.shields.io/travis',
travisTLD === 'com' ? 'com' : '',
githubSlug,
'master.svg',
]
.filter((i) => Boolean(i))
.join('/');
const url = `http://travis-ci.${travisTLD}/${githubSlug}`;
const alt = 'Travis CI Build Status';
const title = "Check this project's build status on TravisCI";
return badge({ image, alt, url, title });
}
exports.travisci = travisci;
travisci.badgeCategory = 'testing';
/** Codeship Badge */
function codeship({ codeshipProjectUUID, codeshipProjectID, }) {
// Check
if (!codeshipProjectUUID)
throw new Error('codeshipProjectUUID is missing');
if (!codeshipProjectID)
throw new Error('codeshipProjectID is missing');
// Create
const image = `https://img.shields.io/codeship/${codeshipProjectUUID}/master.svg`;
const url = `https://www.codeship.io/projects/${codeshipProjectID}`;
const alt = 'Codeship Status';
const title = "Check this project's status on Codeship";
return badge({ image, alt, url, title });
}
exports.codeship = codeship;
codeship.badgeCategory = 'testing';
/** Coveralls Badge */
function coveralls({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://img.shields.io/coveralls/${githubSlug}.svg`;
const url = `https://coveralls.io/r/${githubSlug}`;
const alt = 'Coveralls Coverage Status';
const title = "View this project's coverage on Coveralls";
return badge({ image, alt, url, title });
}
exports.coveralls = coveralls;
coveralls.badgeCategory = 'testing';
/** Code Climate Rating Badge */
function codeclimate({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://img.shields.io/codeclimate/github/${githubSlug}.svg`;
const url = `https://codeclimate.com/github/${githubSlug}`;
const alt = 'Code Climate Rating';
const title = "View this project's rating on Code Climate";
return badge({ image, alt, url, title });
}
exports.codeclimate = codeclimate;
codeclimate.badgeCategory = 'testing';
/** BitHound Score Badge */
function bithound({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://bithound.io/github/${githubSlug}/badges/score.svg`;
const url = `https://bithound.io/github/${githubSlug}`;
const alt = 'BitHound Score';
const title = "View this project's score on BitHound";
return badge({ image, alt, url, title });
}
exports.bithound = bithound;
bithound.badgeCategory = 'testing';
/** Waffle Badge */
function waffle({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const label = 'ready';
const image = `https://badge.waffle.io/${githubSlug}.png?label=${escape(label)}`;
const url = `http://waffle.io/${githubSlug}`;
const alt = 'Stories in Ready';
const title = "View this project's stories on Waffle.io";
return badge({ image, alt, url, title });
}
exports.waffle = waffle;
waffle.badgeCategory = 'testing';
/** Github Workflow Badge */
function githubworkflow({ githubWorkflow, githubBranch, githubEvent, githubSlug, }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
if (!githubWorkflow)
throw new Error('githubWorkflow is missing');
// Create
// https://shields.io/category/build
// https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/adding-a-workflow-status-badge#using-a-workflow-name
const image = new URL(`https://github.com/${githubSlug}/workflows/${githubWorkflow}/badge.svg`);
if (githubBranch)
image.searchParams.set('branch', githubBranch);
if (githubEvent)
image.searchParams.set('event', githubEvent);
const link = new URL(`https://github.com/${githubSlug}/actions`);
link.searchParams.set('query', `workflow:${githubWorkflow}`);
const alt = `Status of the GitHub Workflow: ${githubWorkflow}`;
const title = `View the status of this project's GitHub Workflow: ${githubWorkflow}`;
return badge({ image: image.toString(), url: link.toString(), alt, title });
}
exports.githubworkflow = githubworkflow;
githubworkflow.badgeCategory = 'testing';
/** 60devs Tips Badge */
function sixtydevstips({ sixtydevstipsID, sixtydevstipsURL, }) {
// Check
if (!sixtydevstipsURL) {
if (!sixtydevstipsID)
throw new Error('sixtydevstipsID is missing');
sixtydevstipsURL = `https://tips.60devs.com/tip/${sixtydevstipsID}`;
}
// Create
const image = 'https://img.shields.io/badge/60devs-donate-yellow.svg';
const url = sixtydevstipsURL;
const alt = '60devs tips donate button';
const title = 'Donate to this project using 60devs tips';
return badge({ image, alt, url, title });
}
exports.sixtydevstips = sixtydevstips;
sixtydevstips.badgeCategory = 'funding';
/** Github Sponsors Badge */
function githubsponsors({ githubSponsorsURL, githubSponsorsUsername, githubUsername, }) {
if (!githubSponsorsURL) {
if (!githubSponsorsUsername && !githubUsername)
throw new Error('githubSponsorsUsername and githubUsername are missing');
githubSponsorsURL = `https://github.com/sponsors/${githubSponsorsUsername || githubUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/github-donate-yellow.svg';
const url = githubSponsorsURL;
const alt = 'GitHub Sponsors donate button';
const title = 'Donate to this project using GitHub Sponsors';
return badge({ image, alt, url, title });
}
exports.githubsponsors = githubsponsors;
githubsponsors.badgeCategory = 'funding';
/** ThanksDev Badge */
function thanksdev({ thanksdevURL, thanksdevGithubUsername, githubUsername, }) {
if (!thanksdevURL) {
if (!thanksdevGithubUsername && !githubUsername)
throw new Error('thanksdevGithubUsername and githubUsername are missing');
thanksdevURL = `https://thanks.dev/u/gh/${thanksdevGithubUsername || githubUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/thanksdev-donate-yellow.svg';
const url = thanksdevURL;
const alt = 'ThanksDev donate button';
const title = 'Donate to this project using ThanksDev';
return badge({ image, alt, url, title });
}
exports.thanksdev = thanksdev;
thanksdev.badgeCategory = 'funding';
/** Patreon Badge */
function patreon({ patreonUsername, patreonURL, }) {
// Check
if (!patreonURL) {
if (!patreonUsername)
throw new Error('patreonUsername is missing');
patreonURL = `https://patreon.com/${patreonUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/patreon-donate-yellow.svg';
const url = patreonURL;
const alt = 'Patreon donate button';
const title = 'Donate to this project using Patreon';
return badge({ image, alt, url, title });
}
exports.patreon = patreon;
patreon.badgeCategory = 'funding';
/** Open Collective Badge */
function opencollective({ opencollectiveUsername, opencollectiveURL, }) {
// Check
if (!opencollectiveURL) {
if (!opencollectiveUsername)
throw new Error('opencollectiveUsername is missing');
opencollectiveURL = `https://opencollective.com/${opencollectiveUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/open%20collective-donate-yellow.svg';
const url = opencollectiveURL;
const alt = 'Open Collective donate button';
const title = 'Donate to this project using Open Collective';
return badge({ image, alt, url, title });
}
exports.opencollective = opencollective;
opencollective.badgeCategory = 'funding';
/** Gratipay Badge */
function gratipay({ gratipayUsername, gratipayURL, }) {
// Check
if (!gratipayURL) {
if (!gratipayUsername)
throw new Error('gratipayUsername is missing');
gratipayURL = `https://gratipay.com/${gratipayUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/gratipay-donate-yellow.svg';
const url = gratipayURL;
const alt = 'Gratipay donate button';
const title = 'Donate weekly to this project using Gratipay';
return badge({ image, alt, url, title });
}
exports.gratipay = gratipay;
gratipay.badgeCategory = 'funding';
/** Flattr Badge */
function flattr({ flattrCode, flattrUsername, flattrURL, }) {
// Check
if (!flattrURL) {
if (flattrUsername) {
flattrURL = `https://flattr.com/profile/${flattrUsername}`;
}
else if (flattrCode) {
flattrURL = `https://flattr.com/thing/${flattrCode}`;
}
else {
throw new Error('flattrUsername/flattrCode is missing');
}
}
// Create
const image = 'https://img.shields.io/badge/flattr-donate-yellow.svg';
const url = flattrURL;
const alt = 'Flattr donate button';
const title = 'Donate to this project using Flattr';
return badge({ image, alt, url, title });
}
exports.flattr = flattr;
flattr.badgeCategory = 'funding';
/** Paypal Badge */
function paypal({ paypalURL, paypalButtonID, paypalUsername, }) {
// Check
if (!paypalURL) {
if (paypalButtonID) {
paypalURL = `https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=${escape(paypalButtonID)}`;
}
else if (paypalUsername) {
paypalURL = `https://paypal.me/${paypalUsername}`;
}
else {
throw new Error('paypalURL, paypalButtonID, or paypalUsername is missing, at least one must exist');
}
}
// Create
const image = 'https://img.shields.io/badge/paypal-donate-yellow.svg';
const url = paypalURL;
const alt = 'PayPal donate button';
const title = 'Donate to this project using Paypal';
return badge({ image, alt, url, title });
}
exports.paypal = paypal;
paypal.badgeCategory = 'funding';
/** Crypto Badge */
function crypto({ cryptoURL, bitcoinURL }) {
// Check
const url = cryptoURL || bitcoinURL;
if (!url)
throw new Error('cryptoURL is missing');
// Create
const image = 'https://img.shields.io/badge/crypto-donate-yellow.svg';
const alt = 'crypto donate button';
const title = 'Donate to this project using Cryptocurrency';
return badge({ image, alt, url, title });
}
exports.crypto = crypto;
crypto.badgeCategory = 'funding';
/** @deprecated */
function bitcoin(opts) {
return crypto(opts);
}
exports.bitcoin = bitcoin;
bitcoin.badgeCategory = 'funding';
/** Wishlist Badge */
function wishlist({ wishlistURL }) {
// Check
if (!wishlistURL)
throw new Error('wishlistURL is missing');
// Create
const image = 'https://img.shields.io/badge/wishlist-donate-yellow.svg';
const url = wishlistURL;
const alt = 'Wishlist browse button';
const title = 'Buy an item on our wishlist for us';
return badge({ image, alt, url, title });
}
exports.wishlist = wishlist;
wishlist.badgeCategory = 'funding';
/** Buy Me A Coffee Badge */
function buymeacoffee({ buymeacoffeeUsername, buymeacoffeeURL, }) {
// Check
if (!buymeacoffeeURL) {
if (!buymeacoffeeUsername)
throw new Error('buymeacoffeeUsername is missing');
buymeacoffeeURL = `https://buymeacoffee.com/${buymeacoffeeUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg';
const url = buymeacoffeeURL;
const alt = 'Buy Me A Coffee donate button';
const title = 'Donate to this project using Buy Me A Coffee';
return badge({ image, alt, url, title });
}
exports.buymeacoffee = buymeacoffee;
buymeacoffee.badgeCategory = 'funding';
/** Liberapay Badge */
function liberapay({ liberapayUsername, liberapayURL, }) {
// Check
if (!liberapayURL) {
if (!liberapayUsername)
throw new Error('liberapayUsername is missing');
liberapayURL = `https://liberapay.com/${liberapayUsername}`;
}
// Create
const image = 'https://img.shields.io/badge/liberapay-donate-yellow.svg';
const url = liberapayURL;
const alt = 'Liberapay donate button';
const title = 'Donate to this project using Liberapay';
return badge({ image, alt, url, title });
}
exports.liberapay = liberapay;
liberapay.badgeCategory = 'funding';
/** Thanks App Badge */
function thanksapp({ npmPackageName, githubSlug, thanksappUsername, thanksappURL, }) {
// Check
if (!thanksappURL) {
if (thanksappUsername) {
thanksappURL = `https://givethanks.app/u/${thanksappUsername}`;
}
else if (npmPackageName) {
thanksappURL = `https://givethanks.app/donate/npm/${npmPackageName}`;
}
else if (githubSlug) {
thanksappURL = `https://givethanks.app/donate/github/${githubSlug}`;
}
else {
throw new Error('at least one of these is required: thanksappUsername, npmPackageName, githubSlug');
}
}
// Create
const image = 'https://img.shields.io/badge/thanksapp-donate-yellow.svg';
const url = thanksappURL;
const alt = 'Thanks App donate button';
const title = 'Donate to this project using Thanks App';
return badge({ image, alt, url, title });
}
exports.thanksapp = thanksapp;
thanksapp.badgeCategory = 'funding';
/** Boost Lab Badge */
function boostlab({ githubSlug }) {
// Check
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = 'https://img.shields.io/badge/boostlab-donate-yellow.svg';
const url = `https://boost-lab.app/${githubSlug}`;
const alt = 'Boost Lab donate button';
const title = 'Donate to this project using Boost Lab';
return badge({ image, alt, url, title });
}
exports.boostlab = boostlab;
boostlab.badgeCategory = 'funding';
/** Slackin Script Badge */
function slackinscript({ slackinURL }) {
// Check
if (!slackinURL)
throw new Error('slackinURL is missing');
// Create
return `<script async defer src="${slackinURL}/slackin.js"></script>`;
}
exports.slackinscript = slackinscript;
slackinscript.badgeCategory = 'social';
slackinscript.badgeScript = true;
/** Slackin Badge */
function slackin({ slackinURL }) {
// Check
if (!slackinURL)
throw new Error('slackinURL is missing');
// Create
const image = `${slackinURL}/badge.svg`;
const url = slackinURL;
const alt = 'Slack community badge';
const title = "Join this project's community on Slack";
return badge({ image, alt, url, title });
}
exports.slackin = slackin;
slackin.badgeCategory = 'social';
/** Discord Badge */
function discord({ discordServerID, discordServerInvite, }) {
// Check
if (!discordServerID)
throw new Error('discordServerID is missing');
discordServerInvite = (discordServerInvite || '')
.replace('https://discord.com/invite/', '')
.replace('https://discord.gg/', '');
// Create
const image = `https://img.shields.io/discord/${discordServerID}?logo=discord&label=discord`;
const url = discordServerInvite
? `https://discord.gg/${discordServerInvite}`
: `https://discord.com/channels/${discordServerID}`;
const alt = 'Discord server badge';
const title = "Join this project's community on Discord";
return badge({ image, alt, url, title });
}
exports.discord = discord;
slackin.badgeCategory = 'social';
/** Twitch Badge */
function twitch({ twitchUsername }) {
// Check
if (!twitchUsername)
throw new Error('twitchUsername is missing');
// Create
const image = `https://img.shields.io/twitch/status/${twitchUsername}?logo=twitch`;
const url = `https://www.twitch.tv/${twitchUsername}`;
const alt = 'Twitch community badge';
const title = "Join this project's community on Twitch";
return badge({ image, alt, url, title });
}
exports.twitch = twitch;
slackin.badgeCategory = 'social';
/**
* Google Analytics Beacon Badge
* https://github.com/igrigorik/ga-beacon
*/
function gabeacon({ gaTrackingID, githubSlug, }) {
// Check
if (!gaTrackingID)
throw new Error('gaTrackingID is missing');
if (!githubSlug)
throw new Error('githubSlug is missing');
// Create
const image = `https://ga-beacon.appspot.com/${gaTrackingID}/${githubSlug}`;
const url = 'https://github.com/igrigorik/ga-beacon';
const alt = 'Google Analytics beacon image';
const title = 'Get Google Analytics for your project';
return badge({ image, alt, url, title });
}
exports.gabeacon = gabeacon;
gabeacon.badgeCategory = 'social';
/** Google Plus One Button */
function googleplusone({ homepage }) {
// Check
if (!homepage)
throw new Error('homepage is missing');
// Create
return `<span class="g-plusone" data-size="medium" data-href="${homepage}"></span><script>(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = '//apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);})();</script>`;
}
exports.googleplusone = googleplusone;
googleplusone.badgeCategory = 'social';
googleplusone.badgeScript = true;
/** Reddit Submit Button */
function redditsubmit({ homepage }) {
// Check
if (!homepage)
throw new Error('homepage is missing');
// Create
return `<script>reddit_url="${homepage}"</script><script src="https://en.reddit.com/static/button/button1.js"></script>`;
}
exports.redditsubmit = redditsubmit;
redditsubmit.badgeCategory = 'social';
redditsubmit.badgeScript = true;
/** Hacker News Submit Button */
function hackernewssubmit({ homepage }) {
// Check
if (!homepage)
throw new Error('homepage is missing');
// Create
return `<a href="https://news.ycombinator.com/submit" class="hn-button" data-url="${homepage}" data-count="horizontal">Vote on Hacker News</a><script>var HN=[];HN.factory=function(e){return function(){HN.push([e].concat(Array.prototype.slice.call(arguments,0)))};},HN.on=HN.factory("on"),HN.once=HN.factory("once"),HN.off=HN.factory("off"),HN.emit=HN.factory("emit"),HN.load=function(){var e="hn-button.js";if(document.getElementById(e))return;var t=document.createElement("script");t.id=e,t.src="https://hn-button.herokuapp.com/hn-button.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},HN.load();</script>`;
}
exports.hackernewssubmit = hackernewssubmit;
hackernewssubmit.badgeCategory = 'social';
hackernewssubmit.badgeScript = true;
/** Facebook Like Button */
function facebooklike({ homepage, facebookApplicationID, }) {
// Prepare
if (!homepage)
throw new Error('homepage is missing');
facebookApplicationID = facebookApplicationID || env.FACEBOOK_APPLICATION_ID;
if (!facebookApplicationID)
throw new Error('facebookApplicationID is missing');
// Return
return `<iframe src="https://www.facebook.com/plugins/like.php?href=${escape(homepage)}&send=false&layout=button_count&width=450&show_faces=false&font&colorscheme=light&action=like&height=21&appId=${escape(facebookApplicationID)}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>`;
}
exports.facebooklike = facebooklike;
facebooklike.badgeCategory = 'social';
facebooklike.badgeScript = true;
/** Facebook Follow Button */
function facebookfollow({ facebookUsername, facebookApplicationID, }) {
// Prepare
if (!facebookUsername)
throw new Error('facebookUsername is missing');
facebookApplicationID = facebookApplicationID || env.FACEBOOK_APPLICATION_ID;
if (!facebookApplicationID)
throw new Error('facebookApplicationID is missing');
// Return
return `<iframe src="https://www.facebook.com/plugins/follow.php?href=https%3A%2F%2Fwww.facebook.com%2F${escape(facebookUsername)}&layout=button_count&show_faces=false&colorscheme=light&font&width=450&appId=${escape(facebookApplicationID)}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height: 20px;" allowTransparency="true"></iframe>`;
}
exports.facebookfollow = facebookfollow;
facebookfollow.badgeCategory = 'social';
facebookfollow.badgeScript = true;
/** Twitter Tweet Button */
function twittertweet({ twitterUsername }) {
// Prepare
if (!twitterUsername)
throw new Error('twitterUsername is missing');
// Return
return `<a href="https://twitter.com/share" class="twitter-share-button" data-via="${twitterUsername}" data-related="${twitterUsername}">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>`;
}
exports.twittertweet = twittertweet;
twittertweet.badgeCategory = 'social';
twittertweet.badgeScript = true;
/** Twitter Follow Button */
function twitterfollow({ twitterUsername }) {
// Prepare
if (!twitterUsername)
throw new Error('twitterUsername is missing');
// Return
return `<a href="https://twitter.com/${escape(twitterUsername)}" class="twitter-follow-button" data-show-count="false">Follow @${twitterUsername}</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>`;
}
exports.twitterfollow = twitterfollow;
twitterfollow.badgeCategory = 'social';
twitterfollow.badgeScript = true;
/** Github Follow Button */
function githubfollow({ githubUsername, }) {
// Prepare
if (!githubUsername)
throw new Error('githubUsername is missing');
// Return
return `<iframe src="https://ghbtns.com/github-btn.html?user=${escape(githubUsername)}&type=follow&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="165" height="20"></iframe>`;
}
exports.githubfollow = githubfollow;
githubfollow.badgeCategory = 'social';
githubfollow.badgeScript = true;
/** GitHub Star Button */
function githubstar({ githubSlug }) {
// Prepare
if (!githubSlug)
throw new Error('githubSlug is missing');
const split = githubSlug.split('/');
const githubUsername = split[0];
const githubRepository = split[1];
if (!githubUsername || !githubRepository)
throw new Error('githubSlug is invalid');
// Return
return `<iframe src="https://ghbtns.com/github-btn.html?user=${escape(githubUsername)}&repo=${escape(githubRepository)}&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>`;
}
exports.githubstar = githubstar;
githubstar.badgeCategory = 'social';
githubstar.badgeScript = true;
/** Quora Follow Button */
function quorafollow({ quoraUsername, quoraRealname, quoraCode, }) {
// Prepare
if (!quoraUsername)
throw new Error('quoraUsername is missing');
quoraRealname = quoraRealname || quoraUsername.replace(/-/g, ' ');
quoraCode = quoraCode || '7N31XJs';
// Return
return `
<span data-name="${quoraUsername}">
Follow <a href="http://www.quora.com/${quoraUsername}">${quoraRealname}</a> on <a href="http://www.quora.com">Quora</a>
<script src="https://www.quora.com/widgets/follow?embed_code=${escape(quoraCode)}"></script>
</span>`.replace(/\n\s*/g, '');
}
exports.quorafollow = quorafollow;
quorafollow.badgeCategory = 'social';
quorafollow.badgeScript = true;