import badgeList from '../static/.meta/badges.json' const examples = [...badgeList.live, ...badgeList.static].reduce((accu, curr) => { return (accu as any).concat(Object.entries(curr.examples)) }, [] as [string, string][]) interface BuilderHelperProps { host?: string; badgeURL: string; onSelect: (value: string) => void; } export default function BuilderHelper ({ badgeURL, onSelect }: BuilderHelperProps) { if (badgeURL.length < 2) { return
} const matched = examples.filter(eg => eg[0].includes(badgeURL)) const hints = matched.length === 1 && matched[0][0] === '/' + badgeURL ? null : ( { matched.map(eg => ( onSelect(eg[0].replace(/^\//, ''))} /> )) }
) return (
{hints}
) } const Hint = ({ info, onSelect }) => ( {info[1]} {info[0]} )