README
linkify-hash
Link your Github commit hashes
Table of Contents
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
- userName -
string
- repoName -
string
- attributes -
object
- class -
string
- multiple -
string
|number
|boolean
|string[]
- target -
string
- class -
- baseUrl -
string
- default - https://github.com
- type -
string
- default - "string"
- string gives a normal string with HTML
- dom gives a DocumentFragment with HTML
Related
- create-html-element - Create HTML Element
- jest - Jest
- JSDOM - Javascript DOM in Node.js
License
MIT © Sundeep Charan Ramkumar