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'
|
'/badge/code%20style/standard/f2a': 'code style: standard'
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
title: 'Options',
|
title: 'With Options',
|
||||||
examples: {
|
examples: {
|
||||||
'/badge/icon/github?icon=github': 'use builtin icon',
|
'/badge/icon/github?icon=github': 'use builtin icon',
|
||||||
'/badge/github/github?icon': 'use builtin icon (by subject)',
|
'/badge/github/github?icon': 'use builtin icon (by subject)',
|
||||||
'/badge/jQuery/powered?icon=https://simpleicons.now.sh/jquery/fff': 'use external icon',
|
'/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/icon/github?label': 'disable label',
|
||||||
'/badge/github/github?icon&label': 'use icon, disable label',
|
'/badge/github/github?icon&label': 'use icon, disable label',
|
||||||
'/badge/platform/ios,macos,tvos?list=|': 'list (custom seprator)'
|
'/badge/platform/ios,macos,tvos?list=|': 'list (custom seprator)'
|
||||||
|
|
|
@ -10,6 +10,10 @@ export default function genHelp (id) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id === 'badge') {
|
||||||
|
return genStaticBadgeHelp(badgeModule.examples)
|
||||||
|
}
|
||||||
|
|
||||||
const { meta, handlers } = badgeModule
|
const { meta, handlers } = badgeModule
|
||||||
const { examples, help = ''} = meta
|
const { examples, help = ''} = meta
|
||||||
const routes = Object.keys(handlers)
|
const routes = Object.keys(handlers)
|
||||||
|
@ -39,10 +43,7 @@ export default function genHelp (id) {
|
||||||
|
|
||||||
// category example list
|
// category example list
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const egList = egs.map(([url, desc]) => {
|
md += egs.map(egLine).join('\n')
|
||||||
return `-  [${url}](${url}) <i>${desc}</i>`
|
|
||||||
})
|
|
||||||
md += egList.join('\n')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return md
|
return md
|
||||||
|
@ -54,3 +55,17 @@ function hashify (str: string) {
|
||||||
// return str.replace(/[^\w]/g, '')
|
// return str.replace(/[^\w]/g, '')
|
||||||
return str.split(/[^\w]+/).filter(Boolean).join('-')
|
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