import examplesLive from '../libs/examples-live.js' import examplesStatic from '../libs/examples-static.js' const egs = Object.entries({ ...examplesLive, ...examplesStatic }) .reduce((accu, curr) => { return accu.concat(curr[1].map(eg => eg.concat(curr[0]))) }, []) export default ({ badgeURL, onSelect }) => { const matched = badgeURL.length > 1 && egs.filter(eg => { return eg.find(str => str.includes(badgeURL)) }) const hints = matched.length === 1 && matched[0][1] === '/' + badgeURL ? [] : matched return (
{ hints.length ? ( { hints.map(eg => ( onSelect(eg[1].replace(/^\//, ''))} /> )) }
) : ( '' )}
) } const Hint = ({ info, onSelect }) => ( {info[2]} {info[1]} )