Gets Shields.io badge data.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.vscode
src
.eslintrc.json
.gitignore
.npmignore
.travis.yml
SERVICES-TODO.md
package-lock.json
package.json
readme.md
tsconfig.json

readme.md

shields-badge-data

Badge: npm version badge for package shields-badge-data Build Status Greenkeeper badge

Gets Shields.io badge data.

API

shieldsBadgeData(badgeName, badgeArgs, options?) => BadgeData

  • badgeName is one of these. For example, 'travisCi'.
  • badgeArgs: A set of arguments for the specific badge. See badge specs.
  • options?
    • rootImageUrl?: a root URL, for the case where you’re using your own badges server.
    • format?: 'svg', 'png', 'json', etc.
    • urlParams?
  • BadgeData:
    • title: Badge title. Useful for the alt attribute of an img element, for example.
    • image: A URL for the shields.io badge image.
    • link: A service specific URL.

URLs

URLs are WHATWG URL objects. The package.json browser field is used so that:

Example

import shieldsBadgeData from 'shields-badge-data'

const { title, image, link } = shieldsBadgeData('travisCi', { userRepo: 'foo/bar' })

title
// 'Travis CI build status badge for `foo/bar`'
image.href
// 'https://img.shields.io/travis/foo/bar.svg'
link.href
// 'https://travis-ci.org/foo/bar'