kopia lustrzana https://github.com/badgen/badgen
Add README.md
rodzic
6638258a61
commit
df5ee531ae
|
@ -0,0 +1,20 @@
|
|||
# badgen
|
||||
|
||||
Fast, handcraft, pure JavaScript badge generator.
|
||||
|
||||
## Usage
|
||||
|
||||
### Micro Service
|
||||
|
||||
https://badgen.now.sh/badge/:subject/:status/:color
|
||||
|
||||
- `subject` Text
|
||||
- `status` Text
|
||||
- `color` RGB color (default '4C1')
|
||||
|
||||
![](https://badgen.now.sh/badge/build/passing)
|
||||
![](https://badgen.now.sh/badge/style/standard/f2a)
|
||||
|
||||
### As npm package
|
||||
|
||||
```npm install badgen```
|
4
index.js
4
index.js
|
@ -6,11 +6,11 @@ module.exports = function ({subject, status, color = '4C1'}) {
|
|||
const charWidth = 7.3
|
||||
|
||||
const sbTextWidth = subject.length * charWidth
|
||||
const sbRectWidth = sbTextWidth + 12
|
||||
const sbRectWidth = sbTextWidth + 10
|
||||
const sbTextCenter = sbRectWidth / 2
|
||||
|
||||
const stTextWidth = status.length * charWidth
|
||||
const stRectWidth = stTextWidth + 14
|
||||
const stRectWidth = stTextWidth + 12
|
||||
const stTextCenter = sbRectWidth + stRectWidth / 2 - 1
|
||||
|
||||
const width = sbRectWidth + stRectWidth
|
||||
|
|
|
@ -7,8 +7,14 @@ function generate (req, res, params) {
|
|||
res.end(badgen(params))
|
||||
}
|
||||
|
||||
const readme = require('fs').readFileSync('./README.md', 'utf-8')
|
||||
function serveReadme (req, res) {
|
||||
res.end(readme)
|
||||
}
|
||||
|
||||
router.get('/badge/:subject/:status', generate)
|
||||
router.get('/badge/:subject/:status/:color', generate)
|
||||
router.get('/', serveReadme)
|
||||
|
||||
const server = http.createServer((req, res) => router.lookup(req, res))
|
||||
server.listen(3000)
|
||||
|
|
Ładowanie…
Reference in New Issue