Socket
Socket
Sign inDemoInstall

github-buttons

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-buttons

GitHub Buttons


Version published
Weekly downloads
34K
increased by3.15%
Maintainers
1
Weekly downloads
 
Created
Source

github-buttons

CircleCI Codecov

Usage

Use as a Snippet

Get started quickly with github:button configurator.

The source code for the configurator is available at ntkme/github-buttons-app.

Use as a Module

import { render } from 'github-buttons'

// export function render(anchor: HTMLAnchorElement, callback: (el: HTMLElement) => void): void;
render(anchor, function (el) {
  anchor.parentNode.replaceChild(el, anchor)
})

// export function render(options: object, callback: (el: HTMLElement) => void): void;
render(options, function (el) {
  document.body.appendChild(el) 
})

Use as a Component

Options

These options are the same for all the use cases described above:

AttributeDescription
hrefGitHub link for the button.
titletitle attribute for the button's rendered element.
data-iconocticon-mark-github by default. A subset of Octicons is bundled.
data-sizeNone by default or large.
data-show-countfalse by default or true. The dynamic count is generated based on detected button type.
data-textText displayed on the button. It defaults to the text content within the link.
aria-labelAira label for the button link.
Built-in Button Types

Button type is detected from href.

  • https://github.com/:user (follow)
  • https://github.com/:user/:repo (star)
  • https://github.com/:user/:repo/subscription (watch)
  • https://github.com/:user/:repo/fork (fork)
  • https://github.com/:user/:repo/issues (issues)
  • https://github.com/:user/:repo/issues/new (issues)

Tailing slash, query string, and hash in the href won't affect type detection.

  • https://github.com/:user/ (follow)
  • https://github.com/:user?tab=repositories (follow)
  • https://github.com/:user/:repo#readme (star)
  • https://github.com/:user/:repo/#readme (star)

Development

Clone

git clone https://github.com/ntkme/github-buttons.git
cd github-buttons && npm install

Build

npm run build

Test

npm test

See also

License

See LICENSE.

Keywords

FAQs

Package last updated on 11 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc