linkify-hash

Linkify Github commit Hashes

Usage no npm install needed!

<script type="module">
  import linkifyHash from 'https://cdn.skypack.dev/linkify-hash';
</script>

README

linkify-hash

NPM Version Travis Build NPM Downloads MIT License

Link your Github commit hashes

Table of Contents

  1. Installation
  2. Example
  3. Usage
  4. Related
  5. License

Installation


$ npm install linkify-hash

Example


const linkifyHash = require("linkify-hash");
const commitHash = '0d7ad26e00ff42e6971f3eb3081503fffd48fe98'

const options = {
  userName: 'sunguru98'
  repoName: 'AlgoLoad',
  attributes: {
    class: 'commitHash',
    target: '_blank'
  }
}

const htmlString = linkifyHash(commitHash, options)
// <a href='https://github.com/sunguru98/AlgoLoad/commit/0d7ad26e00ff42e6971f3eb3081503fffd48fe98'

const fragment = linkifyHash(commitHash, {
  ...options,
  type: 'hash'
})

document.body.appendChild(fragment)

API


linkifyHash(hashString, [options])

hashString

Type: string Hash string available in commit.

options

Type: object

  1. userName - string
  2. repoName - string
  3. attributes - object
    • class - string
    • multiple - string | number | boolean | string[]
    • target - string
  4. baseUrl - string
  5. type - string
    • default - "string"
    • string gives a normal string with HTML
    • dom gives a DocumentFragment with HTML

Related


License


MIT © Sundeep Charan Ramkumar