kopia lustrzana https://github.com/badgen/badgen.net
Fix badges.json generator
rodzic
07a08c86a8
commit
6a91506280
|
@ -31,7 +31,7 @@ export function badgenServe (handlers: BadgenServeHandlers): Function {
|
|||
|
||||
// Serve docs
|
||||
if (matchRoute(`/${name}`, pathname)) {
|
||||
return serveDocs(req, res)
|
||||
return serveDocs(req, res, name)
|
||||
}
|
||||
|
||||
// Find handler
|
||||
|
|
|
@ -1,31 +1,18 @@
|
|||
// import path from 'path'
|
||||
|
||||
import path from 'path'
|
||||
import matchRoute from 'my-way'
|
||||
|
||||
const { live: liveBadges } = require('../static/.meta/badges.json')
|
||||
|
||||
/** not supported on Now */
|
||||
// export const liveBadges = liveBadgeList.reduce((accu, curr) => {
|
||||
// const { meta, handlers } = require(path.resolve(__dirname, `../endpoints/${curr}`))
|
||||
// const { title, examples, help } = meta
|
||||
// accu[curr] = {
|
||||
// id: curr,
|
||||
// title,
|
||||
// examples,
|
||||
// routes: Object.keys(handlers),
|
||||
// help
|
||||
// }
|
||||
// return accu
|
||||
// }, {})
|
||||
|
||||
export default function genHelp (id) {
|
||||
const meta = liveBadges.find(b => b.id === id)
|
||||
let badgeModule
|
||||
|
||||
if (!meta) {
|
||||
try {
|
||||
badgeModule = require(path.resolve(__dirname, '../endpoints', id))
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
|
||||
const { examples, routes, help = '' } = meta
|
||||
const { meta, handlers } = badgeModule
|
||||
const { examples, help = ''} = meta
|
||||
const routes = Object.keys(handlers)
|
||||
|
||||
let md = `# /${id}\n\n${help}`
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ import serveMarked from 'serve-marked'
|
|||
import serve404 from '../libs/serve-404'
|
||||
import genHelp from '../libs/gen-help'
|
||||
|
||||
export default async function (req, res) {
|
||||
const [ , name ] = req.url.split('/')
|
||||
export default async function (req, res, name) {
|
||||
const helpMarkdown = genHelp(name)
|
||||
|
||||
if (helpMarkdown) {
|
||||
|
|
Ładowanie…
Reference in New Issue