Support new model sources format [ci skip]

This commit is contained in:
Ines Montani 2019-09-18 11:42:45 +02:00
parent a84025d70b
commit ea2a686cf7

View File

@ -108,6 +108,17 @@ function formatModelMeta(data) {
} }
} }
function formatSources(data = []) {
const sources = Array.isArray(data) ? data.map(s => ({ name: s })) : data
return sources.map(({ name, url, author }, i) => (
<>
{i > 0 && ', '}
{name && url ? <Link to={url}>{name}</Link> : name}
{author && ` (${author})`}
</>
))
}
const Help = ({ children }) => ( const Help = ({ children }) => (
<span data-tooltip={children}> <span data-tooltip={children}>
<Icon name="help2" width={16} variant="subtle" inline /> <Icon name="help2" width={16} variant="subtle" inline />
@ -142,7 +153,7 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
const releaseUrl = `https://github.com/${repo}/releases/${releaseTag}` const releaseUrl = `https://github.com/${repo}/releases/${releaseTag}`
const pipeline = const pipeline =
meta.pipeline && join(meta.pipeline.map(p => <InlineCode key={p}>{p}</InlineCode>)) meta.pipeline && join(meta.pipeline.map(p => <InlineCode key={p}>{p}</InlineCode>))
const sources = meta.sources && join(meta.sources) const sources = formatSources(meta.sources)
const author = !meta.url ? meta.author : <Link to={meta.url}>{meta.author}</Link> const author = !meta.url ? meta.author : <Link to={meta.url}>{meta.author}</Link>
const licenseUrl = licenses[meta.license] ? licenses[meta.license].url : null const licenseUrl = licenses[meta.license] ? licenses[meta.license].url : null
const license = licenseUrl ? <Link to={licenseUrl}>{meta.license}</Link> : meta.license const license = licenseUrl ? <Link to={licenseUrl}>{meta.license}</Link> : meta.license