💫 Update website (#3285)
<!--- Provide a general summary of your changes in the title. -->
## Description
The new website is implemented using [Gatsby](https://www.gatsbyjs.org) with [Remark](https://github.com/remarkjs/remark) and [MDX](https://mdxjs.com/). This allows authoring content in **straightforward Markdown** without the usual limitations. Standard elements can be overwritten with powerful [React](http://reactjs.org/) components and wherever Markdown syntax isn't enough, JSX components can be used. Hopefully, this update will also make it much easier to contribute to the docs. Once this PR is merged, I'll implement auto-deployment via [Netlify](https://netlify.com) on a specific branch (to avoid building the website on every PR). There's a bunch of other cool stuff that the new setup will allow us to do – including writing front-end tests, service workers, offline support, implementing a search and so on.
This PR also includes various new docs pages and content.
Resolves #3270. Resolves #3222. Resolves #2947. Resolves #2837.
### Types of change
enhancement
## Checklist
<!--- Before you submit the PR, go over this checklist and make sure you can
tick off all the boxes. [] -> [x] -->
- [x] I have submitted the spaCy Contributor Agreement.
- [x] I ran the tests, and all new and existing tests passed.
- [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
2019-02-17 21:31:19 +03:00
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 , 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 , pageContext , location , mdxComponents } ) => {
const { theme , 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 (
< >
< Sidebar items = { sidebar } slug = { slug } / >
< Main section = "universe" theme = { theme } sidebar asides wrapContent footer = { < Footer / > } >
{ activeData ? (
< Project data = { activeData } components = { markdownComponents } / >
) : (
< Section >
{ isHome ? (
< Title
title = "Universe"
teaser = "This section collects the many great resources developed with or for spaCy. It includes standalone packages, plugins, extensions, educational materials, operational utilities and bindings for other languages."
/ >
) : (
< Title
title = { data . title }
teaser = { data . description }
tag = { String ( filteredResources . length ) }
/ >
) }
2019-03-14 18:51:29 +03:00
< Grid
cols = { data && data . isCategory && data . id === 'books' ? 3 : 2 }
className = "search-exclude"
>
💫 Update website (#3285)
<!--- Provide a general summary of your changes in the title. -->
## Description
The new website is implemented using [Gatsby](https://www.gatsbyjs.org) with [Remark](https://github.com/remarkjs/remark) and [MDX](https://mdxjs.com/). This allows authoring content in **straightforward Markdown** without the usual limitations. Standard elements can be overwritten with powerful [React](http://reactjs.org/) components and wherever Markdown syntax isn't enough, JSX components can be used. Hopefully, this update will also make it much easier to contribute to the docs. Once this PR is merged, I'll implement auto-deployment via [Netlify](https://netlify.com) on a specific branch (to avoid building the website on every PR). There's a bunch of other cool stuff that the new setup will allow us to do – including writing front-end tests, service workers, offline support, implementing a search and so on.
This PR also includes various new docs pages and content.
Resolves #3270. Resolves #3222. Resolves #2947. Resolves #2837.
### Types of change
enhancement
## Checklist
<!--- Before you submit the PR, go over this checklist and make sure you can
tick off all the boxes. [] -> [x] -->
- [x] I have submitted the spaCy Contributor Agreement.
- [x] I ran the tests, and all new and existing tests passed.
- [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
2019-02-17 21:31:19 +03:00
{ 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 = ""
/ >
)
return cover ? (
< p key = { id } >
< Link key = { id } to = { url } hidden >
< img src = { cover } alt = { title || id } / >
< / L i n k >
< / p >
) : (
< Card
key = { id }
title = { title || id }
image = { thumb }
to = { url }
header = { header }
>
{ slogan }
< / C a r d >
)
}
) }
< / G r i d >
< / S e c t i o n >
) }
2019-03-14 18:51:29 +03:00
< section className = "search-exclude" >
💫 Update website (#3285)
<!--- Provide a general summary of your changes in the title. -->
## Description
The new website is implemented using [Gatsby](https://www.gatsbyjs.org) with [Remark](https://github.com/remarkjs/remark) and [MDX](https://mdxjs.com/). This allows authoring content in **straightforward Markdown** without the usual limitations. Standard elements can be overwritten with powerful [React](http://reactjs.org/) components and wherever Markdown syntax isn't enough, JSX components can be used. Hopefully, this update will also make it much easier to contribute to the docs. Once this PR is merged, I'll implement auto-deployment via [Netlify](https://netlify.com) on a specific branch (to avoid building the website on every PR). There's a bunch of other cool stuff that the new setup will allow us to do – including writing front-end tests, service workers, offline support, implementing a search and so on.
This PR also includes various new docs pages and content.
Resolves #3270. Resolves #3222. Resolves #2947. Resolves #2837.
### Types of change
enhancement
## Checklist
<!--- Before you submit the PR, go over this checklist and make sure you can
tick off all the boxes. [] -> [x] -->
- [x] I have submitted the spaCy Contributor Agreement.
- [x] I ran the tests, and all new and existing tests passed.
- [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
2019-02-17 21:31:19 +03:00
< H3 > Submit your project < / H 3 >
< 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 < / I n l i n e C o d e >
< / L i n k >
label on the issue tracker .
< / p >
< InlineList >
< Button variant = "primary" to = { github ( 'website/universe/README.md' ) } >
Read the docs
< / B u t t o n >
< Button icon = "code" to = { github ( 'website/meta/universe.json' ) } >
JSON source
< / B u t t o n >
< / I n l i n e L i s t >
< / s e c t i o n >
< / M a i n >
< / >
)
}
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 = ""
/ >
) ) }
< / L i n k >
< / p >
) }
< / T i t l e >
{ data . pip && (
< Aside title = "Installation" >
< CodeBlock lang = "bash" prompt = "$" >
pip install { data . pip }
< / C o d e B l o c k >
< / A s i d e >
) }
{ data . cran && (
< Aside title = "Installation" >
< CodeBlock lang = "r" > install . packages ( "{data.cran}" ) < / C o d e B l o c k >
< / A s i d e >
) }
{ data . cover && (
< p >
< img src = { data . cover } alt = { data . title } width = { 250 } style = { { maxWidth : '50%' } } / >
< / p >
) }
< Section >
{ data . youtube && < YouTube id = { data . youtube } / > }
{ data . soundcloud && < SoundCloud id = { data . soundcloud } title = { data . title } / > }
{ data . iframe && (
< Iframe
src = { data . iframe }
title = { data . title }
width = "100%"
height = { data . iframe _height }
/ >
) }
{ data . description && < section > { markdownToReact ( data . description , components ) } < / s e c t i o n > }
{ data . code _example && (
< CodeBlock title = "Example" lang = { data . code _language || 'python' } >
{ data . code _example . join ( '\n' ) }
< / C o d e B l o c k >
) }
{ data . image && (
< p >
< img src = { data . image } style = { { maxWidth : '100%' } } alt = "" / >
< / p >
) }
{ data . url && (
< Button variant = "primary" to = { data . url } >
View more
< / B u t t o n >
) }
< / S e c t i o n >
< Section >
< Grid cols = { 2 } >
< div >
< Label > Author info < / L a b e l >
< InlineList gutterBottom = { false } >
< span > { data . author } < / s p a n >
< span >
{ data . author _links && data . author _links . twitter && (
< Link
to = { ` https://twitter.com/ ${ data . author _links . twitter } ` }
hidden
ws
>
< Icon width = { 18 } name = "twitter" inline / >
< / L i n k >
) }
{ data . author _links && data . author _links . github && (
< Link
to = { ` https://github.com/ ${ data . author _links . github } ` }
hidden
ws
>
< Icon width = { 18 } name = "github" inline / >
< / L i n k >
) }
{ data . author _links && data . author _links . website && (
< Link to = { data . author _links . website } hidden ws >
< Icon width = { 18 } name = "website" inline / >
< / L i n k >
) }
< / s p a n >
< / I n l i n e L i s t >
< / d i v >
{ data . github && (
< p style = { { marginBottom : 0 } } >
< Label > GitHub < / L a b e l >
< Link to = { ` https://github.com/ ${ data . github } ` } >
< InlineCode wrap > { data . github } < / I n l i n e C o d e >
< / L i n k >
< / p >
) }
< / G r i d >
{ data . category && (
< p style = { { marginBottom : 0 } } >
< Label > Categories < / L a b e l >
{ data . category . map ( cat => (
< Link to = { ` /universe/category/ ${ cat } ` } key = { cat } ws >
< InlineCode > { cat } < / I n l i n e C o d e >
< / L i n k >
) ) }
< / p >
) }
< / S e c t i o n >
< / >
)
const Universe = ( { pageContext , location , mdxComponents } ) => (
< StaticQuery
query = { query }
render = { data => {
const content = data . site . siteMetadata . universe . resources
const categories = data . site . siteMetadata . universe . categories
return (
< UniverseContent
content = { content }
categories = { categories }
pageContext = { pageContext }
location = { location }
mdxComponents = { mdxComponents }
/ >
)
} }
/ >
)
export default Universe
const query = graphql `
query UniverseQuery {
site {
siteMetadata {
universe {
resources {
type
id
title
slogan
url
github
description
pip
cran
category
thumb
image
cover
code _example
code _language
youtube
soundcloud
iframe
iframe _height
author
author _links {
twitter
github
website
}
}
categories {
label
items {
id
title
description
}
}
}
}
}
}
`