import React from 'react' import PropTypes from 'prop-types' import { StaticQuery, graphql } from 'gatsby' import Card from '../components/card' import Link from '../components/link' import Title from '../components/title' import Grid from '../components/grid' import Button from '../components/button' import Icon from '../components/icon' import CodeBlock, { InlineCode } from '../components/code' import Aside from '../components/aside' import Sidebar from '../components/sidebar' import Section from '../components/section' import Main from '../components/main' import Footer from '../components/footer' import { H3, H5, Label, InlineList } from '../components/typography' import { YouTube, SoundCloud, Iframe } from '../components/embed' import { github, markdownToReact } from '../components/util' function getSlug(data) { if (data.isCategory) return `/universe/category/${data.id}` if (data.isProject) return `/universe/project/${data.id}` return `/universe` } function filterResources(resources, data) { const sorted = resources.sort((a, b) => a.id.localeCompare(b.id)) if (!data || !data.isCategory) return sorted return sorted.filter(res => (res.category || []).includes(data.id)) } const UniverseContent = ({ content = [], categories, theme, pageContext, mdxComponents }) => { const { data = {} } = pageContext const filteredResources = filterResources(content, data) const activeData = data ? content.find(({ id }) => id === data.id) : null const markdownComponents = { ...mdxComponents, code: InlineCode } const slug = getSlug(data) const isHome = !data.isCategory && !data.isProject const sidebar = [ { label: 'Overview', items: [{ text: 'All Projects', url: '/universe' }], }, ...categories.map(({ label, items }) => ({ label, items: items.map(({ id, title }) => ({ text: title, url: `/universe/category/${id}`, })), })), ] return ( <>
}> {activeData ? ( ) : (
{isHome ? ( ) : ( <Title title={data.title} teaser={data.description} tag={String(filteredResources.length)} /> )} <Grid cols={data && data.isCategory && data.id === 'books' ? 3 : 2} className="search-exclude" > {filteredResources.map( ({ id, type, title, slogan, thumb, cover, youtube }) => { if (isHome && type === 'education') { return null } const url = `/universe/project/${id}` const header = youtube && ( <img src={`https://img.youtube.com/vi/${youtube}/0.jpg`} alt="" style={{ clipPath: 'inset(12.9% 0)', marginBottom: 'calc(-12.9% + 1rem)', }} /> ) return cover ? ( <p key={id}> <Link key={id} to={url} hidden> <img src={cover} alt={title || id} /> </Link> </p> ) : data.id === 'videos' ? ( <div> <Link key={id} to={url} hidden> {header} <H5>{title}</H5> </Link> </div> ) : ( <Card key={id} title={title || id} image={thumb} to={url} header={header} > {slogan} </Card> ) } )} </Grid> </Section> )} <section className="search-exclude"> <H3>Submit your project</H3> <p> If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the <Link to={github() + '/labels/project%20idea'} hideIcon ws> <InlineCode>project idea</InlineCode> </Link> label on the issue tracker. </p> <InlineList> <Button variant="primary" to={github('website/UNIVERSE.md')}> Read the docs </Button> <Button icon="code" to={github('website/meta/universe.json')}> JSON source </Button> </InlineList> </section> </Main> </> ) } UniverseContent.propTypes = { content: PropTypes.arrayOf(PropTypes.object), categories: PropTypes.arrayOf( PropTypes.shape({ label: PropTypes.string.isRequired, items: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string.isRequired, title: PropTypes.string.isRequired, description: PropTypes.string.isRequired, }) ).isRequired, }) ).isRequired, theme: PropTypes.string, location: PropTypes.object.isRequired, mdxComponents: PropTypes.object, } const Project = ({ data, components }) => ( <> <Title title={data.title || data.id} teaser={data.slogan} image={data.thumb}> {data.github && ( <p> <Link to={`https://github.com/${data.github}`} hidden> {[ `release/${data.github}/all.svg?style=flat-square`, `license/${data.github}.svg?style=flat-square`, `stars/${data.github}.svg?style=social&label=Stars`, ].map((url, i) => ( <img style={{ borderRadius: '1em', marginRight: '0.5rem' }} key={i} src={`https://img.shields.io/github/${url}`} alt="" /> ))} </Link> </p> )} {data.pip && ( )} {data.cran && ( )} {data.cover && (

{data.title}

)}
{data.youtube && } {data.soundcloud && } {data.iframe && (