Amio
6 years ago
15 changed files with 840 additions and 80 deletions
@ -0,0 +1,13 @@ |
|||
export default ({ children, ...args }) => ( |
|||
<div {...args}> |
|||
{children} |
|||
<style jsx>{` |
|||
div { |
|||
margin: 0 20px; |
|||
} |
|||
`}</style>
|
|||
<style jsx global>{` |
|||
@import url('/static/doc-styles.css') |
|||
`}</style>
|
|||
</div> |
|||
) |
@ -1,40 +0,0 @@ |
|||
const fs = require('fs') |
|||
const path = require('path') |
|||
const serveMarked = require('serve-marked') |
|||
const serve404 = require('./serve-404.js') |
|||
|
|||
const serveMarkedOptions = { |
|||
preset: 'merri', |
|||
inlineCSS: ` |
|||
body { max-width: 800px; padding: 0 2rem 5rem 2rem } |
|||
h1 + p { letter-spacing: 0.1px; margin-top: 2em } |
|||
h1 + p + p { text-align: center; margin: 1em 0 } |
|||
img { height: 20px } |
|||
em { font-size: 0.8em; color: #666 } |
|||
li { padding: 0.4em 0 } |
|||
code { padding: 0.4em 0.6em; display: pre } |
|||
pre code { padding: 0 } |
|||
p { margin: 0; line-height: 2em } |
|||
p img + a { vertical-align: top; margin-left: 0.4em; font: 14px/20px monospace } |
|||
`,
|
|||
beforeHeadEnd: `<link rel="icon" type="image/png" href="/static/favicon.png">`, |
|||
trackingGA: process.env.TRACKING_GA || null |
|||
} |
|||
|
|||
const docsFolder = path.join(__dirname, 'docs') |
|||
const docHandlers = fs.readdirSync(docsFolder).reduce((map, filename) => { |
|||
const key = filename.replace('.md', '') |
|||
const title = `Usage of /${key} - Badgen` |
|||
const options = { title, ...serveMarkedOptions } |
|||
map[key] = serveMarked(path.join(docsFolder, filename), options) |
|||
return map |
|||
}, {}) |
|||
|
|||
module.exports = (req, res) => { |
|||
const handler = docHandlers[req.params.topic] |
|||
if (handler) { |
|||
return handler(req, res) |
|||
} else { |
|||
return serve404(req, res) |
|||
} |
|||
} |
@ -1 +1,5 @@ |
|||
module.exports = {} |
|||
const withMDX = require('@zeit/next-mdx')() |
|||
|
|||
module.exports = withMDX({ |
|||
pageExtensions: ['js', 'jsx', 'mdx'] |
|||
}) |
|||
|
File diff suppressed because it is too large
@ -0,0 +1,60 @@ |
|||
export default class extends React.Component { |
|||
componentDidMount () { |
|||
// Generate the icons example |
|||
fetch('/metadata.json') |
|||
.then((resp) => resp.json()) |
|||
.then(json => { |
|||
const blacklist = ['postgresql', 'discord'] |
|||
const icons = document.querySelector('#icon-examples') |
|||
for (const icon of json.icons) { |
|||
if (blacklist.indexOf(icon) !== -1) continue; |
|||
const img = document.createElement('img') |
|||
img.src = `/badge//${icon}?icon=${icon}` |
|||
icons.appendChild(img) |
|||
icons.appendChild(document.createTextNode("\n")) |
|||
} |
|||
}) |
|||
} |
|||
render = () => this.props.children |
|||
} |
|||
|
|||
# Badgen Options |
|||
|
|||
Advance usage of badgen url. |
|||
|
|||
![](/badge/badgen/options) |
|||
|
|||
### Available Color Names |
|||
|
|||
<div>{ |
|||
['blue', 'cyan', 'green', 'yellow', 'orange', 'red', 'pink', 'purple', 'grey'].map(c => { |
|||
return ( |
|||
<a key={`${c}`} href={`/badge/color/${c}/${c}`}> |
|||
<img src={`/badge/color/${c}/${c}`} /> |
|||
</a> |
|||
) |
|||
}) |
|||
}</div> |
|||
|
|||
### Available Icons |
|||
|
|||
<div id="icon-examples"></div> |
|||
|
|||
### Available Query Params |
|||
|
|||
- `icon` Use builtin icon in front of subject text. [e.g.][icon-eg-href] |
|||
- `list` Set `list=1` will replace `,` with ` | ` in status text. [e.g.][list-eg-href] |
|||
- `label` Override default subject text ([URL-Encoding][url-enc-href] needed for spaces or special characters). |
|||
- `color` Override badge color. [e.g.][color-eg-href] |
|||
|
|||
### See Also |
|||
|
|||
- [`/runkit`](/docs/runkit) create arbitrary live badge with RunKit's online IDE. |
|||
- [`/https`](/docs/https) let Badgen serve arbitrary live badge from custom api endpoint. |
|||
|
|||
|
|||
[url-enc-href]: https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding |
|||
[style-eg-href]: /badge/color/blue/blue?style=flat |
|||
[list-eg-href]: /badge/platform/ios,macos,tvos?list=1 |
|||
[icon-eg-href]: /badge/docker/v1.2.3/blue?icon=docker |
|||
[color-eg-href]: /npm/dm/express?color=pink |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue