3.0.2
npm install --save @thebespokepixel/badges
With this source.markdown:
Badges: ${badges}
Read it in as a template and merge the AST:
/* Import the module… */
import {readFileSync} from 'fs'
import _ from 'lodash'
import remark from 'remark'
import badges from 'badges'
/* …then read the 'badges.readme' stanza from package.json and send the AST into remark etc. */
const content = {
badges: await badges('readme')
}
const template = _.template(readFileSync('./source.markdown'))
const page = await remark().process(template(content))
In package.json
...
...
"badges": {
"github": "MarkGriffiths", // github user
"npm": "thebespokepixel", // npm user
"codeclimate": "a0a755b0fce22eb0b784", // codeclimate badge asset id
"name": "badges", // Package name
"style": "square", // Badge style (default 'flat')
"providers": { // Non-default badge provider configuration
"status": {
"text": "beta",
"color": "blue"
},
"aux1": {
"title": "github",
"text": "source",
"color": "4E73B6",
"link": "https://github.com/MarkGriffiths/badges"
}
}
"readme": { // Section with subtitles as map of arrays
"Status": [
[ "status", "npm", "travis", "david" ],
[ "code-climate", "code-climate-coverage", "snyk" ]
],
"Developer": [ "david-dev", "rollup" ],
"Help": [ "inch", "gitter" ]
},
"docs": [ // Lines as an array of arrays
[ "aux1", "travis" ],
[ "code-climate", "code-climate-coverage" ],
[ "david" ]
]
}
- status (plus similar aux1 and aux2)
- travis
- travis-pro (requires a 'travis' token)
- david and david-dev
- code-climate and code-climate-coverage (requires a 'codeclimate' token)
- inch
- npm
- rollup
- snyk
- gitter
> compile-readme --help
Inject project badges into a tagged markdown-formatted source file.
Usage:
compile-readme [options] > outputFile
Options:
-h, --help Display help.
-v, --version Print version to stdout. -vv Print name & version.
-V, --verbose Be verbose. -VV Be loquacious.
-c, --context The named badges context in package.json.
-u, --usage Path to a usage markdown example
--color Force color output. Disable with --no-color
© 2020 The Bespoke Pixel. Released under the MIT License.
Render project badge configuration as markdown.
Promise
:
A promise that resolves to the markdown formatted output.