kopia lustrzana https://github.com/badgen/badgen.net
Handle static badge docs specially
rodzic
6a91506280
commit
fba3de34c1
|
@ -12,12 +12,12 @@ export const examples = [
|
|||
'/badge/code%20style/standard/f2a': 'code style: standard'
|
||||
}
|
||||
}, {
|
||||
title: 'Options',
|
||||
title: 'With Options',
|
||||
examples: {
|
||||
'/badge/icon/github?icon=github': 'use builtin icon',
|
||||
'/badge/github/github?icon': 'use builtin icon (by subject)',
|
||||
'/badge/jQuery/powered?icon=https://simpleicons.now.sh/jquery/fff': 'use external icon',
|
||||
'/badge/icon/github?label=custom label': 'custom label',
|
||||
'/badge/icon/github?label=custom%20label': 'custom label',
|
||||
'/badge/icon/github?label': 'disable label',
|
||||
'/badge/github/github?icon&label': 'use icon, disable label',
|
||||
'/badge/platform/ios,macos,tvos?list=|': 'list (custom seprator)'
|
||||
|
|
|
@ -10,6 +10,10 @@ export default function genHelp (id) {
|
|||
return ''
|
||||
}
|
||||
|
||||
if (id === 'badge') {
|
||||
return genStaticBadgeHelp(badgeModule.examples)
|
||||
}
|
||||
|
||||
const { meta, handlers } = badgeModule
|
||||
const { examples, help = ''} = meta
|
||||
const routes = Object.keys(handlers)
|
||||
|
@ -39,10 +43,7 @@ export default function genHelp (id) {
|
|||
|
||||
// category example list
|
||||
// @ts-ignore
|
||||
const egList = egs.map(([url, desc]) => {
|
||||
return `-  [${url}](${url}) <i>${desc}</i>`
|
||||
})
|
||||
md += egList.join('\n')
|
||||
md += egs.map(egLine).join('\n')
|
||||
})
|
||||
|
||||
return md
|
||||
|
@ -54,3 +55,17 @@ function hashify (str: string) {
|
|||
// return str.replace(/[^\w]/g, '')
|
||||
return str.split(/[^\w]+/).filter(Boolean).join('-')
|
||||
}
|
||||
|
||||
function egLine ([url, desc]) {
|
||||
return `-  [${url}](${url}) <i>${desc}</i>`
|
||||
}
|
||||
|
||||
function genStaticBadgeHelp (staticExamples) {
|
||||
let md = `# Static Badge\n\n`
|
||||
|
||||
md += staticExamples.map(({ title, examples }) => {
|
||||
return `### ${title}\n\n` + Object.entries(examples).map(egLine).join('\n')
|
||||
}).join('\n\n')
|
||||
|
||||
return md
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue