Use generated static help data

pull/282/head
Amio 2019-06-01 22:15:44 +08:00
rodzic 54ef4b0f26
commit 63f5bbb0c5
1 zmienionych plików z 18 dodań i 15 usunięć

Wyświetl plik

@ -1,21 +1,24 @@
import path from 'path'
import { liveBadgeList } from './badge-list'
// import path from 'path'
// import { liveBadgeList } from './badge-list'
const liveBadgeDB = 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
}, {})
const { live: liveBadges } = require('../static/.gen/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 = liveBadgeDB[id]
const meta = liveBadges.find(b => b.id === id)
if (!meta) {
return ''