💫 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 { graphql } from 'gatsby'
|
|
|
|
import { MDXProvider } from '@mdx-js/tag'
|
|
|
|
import { withMDXScope } from 'gatsby-mdx/context'
|
|
|
|
import useOnlineStatus from '@rehooks/online-status'
|
2019-03-18 18:07:26 +03:00
|
|
|
import classNames from 'classnames'
|
💫 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 MDXRenderer from './mdx-renderer'
|
|
|
|
|
|
|
|
// Templates
|
|
|
|
import Docs from './docs'
|
|
|
|
import Universe from './universe'
|
|
|
|
|
|
|
|
// Components
|
|
|
|
import Navigation from '../components/navigation'
|
|
|
|
import Progress from '../components/progress'
|
|
|
|
import Footer from '../components/footer'
|
|
|
|
import SEO from '../components/seo'
|
|
|
|
import Link from '../components/link'
|
|
|
|
import Section, { Hr } from '../components/section'
|
|
|
|
import { Table, Tr, Th, Td } from '../components/table'
|
|
|
|
import { Pre, Code, InlineCode } from '../components/code'
|
|
|
|
import { Ol, Ul, Li } from '../components/list'
|
|
|
|
import { H2, H3, H4, H5, P, Abbr, Help } from '../components/typography'
|
|
|
|
import Accordion from '../components/accordion'
|
|
|
|
import Infobox from '../components/infobox'
|
|
|
|
import Aside from '../components/aside'
|
|
|
|
import Button from '../components/button'
|
|
|
|
import Tag from '../components/tag'
|
|
|
|
import Grid from '../components/grid'
|
|
|
|
import { YouTube, SoundCloud, Iframe, Image } from '../components/embed'
|
|
|
|
import Alert from '../components/alert'
|
2019-02-25 22:11:11 +03:00
|
|
|
import Search from '../components/search'
|
💫 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
|
|
|
|
|
|
|
const mdxComponents = {
|
|
|
|
a: Link,
|
|
|
|
p: P,
|
|
|
|
pre: Pre,
|
|
|
|
code: Code,
|
|
|
|
inlineCode: InlineCode,
|
|
|
|
table: Table,
|
|
|
|
img: Image,
|
|
|
|
tr: Tr,
|
|
|
|
th: Th,
|
|
|
|
td: Td,
|
|
|
|
ol: Ol,
|
|
|
|
ul: Ul,
|
|
|
|
li: Li,
|
|
|
|
h2: H2,
|
|
|
|
h3: H3,
|
|
|
|
h4: H4,
|
|
|
|
h5: H5,
|
|
|
|
blockquote: Aside,
|
|
|
|
section: Section,
|
|
|
|
wrapper: ({ children }) => children,
|
|
|
|
hr: Hr,
|
|
|
|
}
|
|
|
|
|
|
|
|
const scopeComponents = {
|
|
|
|
Infobox,
|
|
|
|
Table,
|
|
|
|
Tr,
|
|
|
|
Th,
|
|
|
|
Td,
|
|
|
|
Help,
|
|
|
|
Button,
|
|
|
|
YouTube,
|
|
|
|
SoundCloud,
|
|
|
|
Iframe,
|
|
|
|
Abbr,
|
|
|
|
Tag,
|
|
|
|
Accordion,
|
|
|
|
Grid,
|
|
|
|
InlineCode,
|
|
|
|
}
|
|
|
|
|
|
|
|
const AlertSpace = () => {
|
|
|
|
const isOnline = useOnlineStatus()
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{!isOnline && (
|
|
|
|
<Alert title="Looks like you're offline." icon="offline" variant="warning">
|
|
|
|
But don't worry, your visited pages should be saved for you.
|
|
|
|
</Alert>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
class Layout extends React.Component {
|
2019-03-12 17:21:58 +03:00
|
|
|
static defaultProps = {
|
|
|
|
scope: {},
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
data: PropTypes.shape({
|
|
|
|
mdx: PropTypes.shape({
|
|
|
|
code: PropTypes.shape({
|
|
|
|
body: PropTypes.string.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
}),
|
|
|
|
}).isRequired,
|
|
|
|
scope: PropTypes.object.isRequired,
|
|
|
|
pageContext: PropTypes.shape({
|
|
|
|
title: PropTypes.string,
|
|
|
|
section: PropTypes.string,
|
|
|
|
teaser: PropTypes.string,
|
|
|
|
source: PropTypes.string,
|
|
|
|
isIndex: PropTypes.bool.isRequired,
|
|
|
|
theme: PropTypes.string,
|
2019-03-18 18:07:26 +03:00
|
|
|
searchExclude: PropTypes.bool,
|
2019-03-12 17:21:58 +03:00
|
|
|
next: PropTypes.shape({
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
slug: PropTypes.string.isRequired,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
children: PropTypes.node,
|
|
|
|
}
|
|
|
|
|
💫 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
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
// NB: Compiling the scope here instead of in render() is super
|
|
|
|
// important! Otherwise, it triggers unnecessary rerenders of ALL
|
|
|
|
// consumers (e.g. mdx elements), even on anchor navigation!
|
|
|
|
this.state = { scope: { ...scopeComponents, ...props.scope } }
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { data, pageContext, location, children } = this.props
|
|
|
|
const { file, site = {} } = data || {}
|
|
|
|
const mdx = file ? file.childMdx : null
|
2019-03-18 18:07:26 +03:00
|
|
|
const { title, section, sectionTitle, teaser, theme = 'blue', searchExclude } = pageContext
|
|
|
|
const bodyClass = classNames(`theme-${theme}`, { 'search-exclude': !!searchExclude })
|
💫 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
|
|
|
const meta = site.siteMetadata || {}
|
|
|
|
const isDocs = ['usage', 'models', 'api', 'styleguide'].includes(section)
|
|
|
|
const content = !mdx ? null : (
|
|
|
|
<MDXProvider components={mdxComponents}>
|
|
|
|
<MDXRenderer scope={this.state.scope}>{mdx.code.body}</MDXRenderer>
|
|
|
|
</MDXProvider>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<SEO
|
|
|
|
title={title}
|
|
|
|
description={teaser || meta.description}
|
|
|
|
section={section}
|
|
|
|
sectionTitle={sectionTitle}
|
|
|
|
bodyClass={bodyClass}
|
|
|
|
/>
|
|
|
|
<AlertSpace />
|
2019-02-25 22:11:11 +03:00
|
|
|
<Navigation
|
|
|
|
title={meta.title}
|
|
|
|
items={meta.navigation}
|
|
|
|
section={section}
|
|
|
|
search={<Search settings={meta.docSearch} />}
|
|
|
|
>
|
💫 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
|
|
|
<Progress key={location.href} />
|
|
|
|
</Navigation>
|
|
|
|
{isDocs ? (
|
|
|
|
<Docs pageContext={pageContext}>{content}</Docs>
|
|
|
|
) : section === 'universe' ? (
|
|
|
|
<Universe
|
|
|
|
pageContext={pageContext}
|
|
|
|
location={location}
|
|
|
|
mdxComponents={mdxComponents}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
{children}
|
|
|
|
{content}
|
|
|
|
<Footer wide />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 17:21:58 +03:00
|
|
|
export default withMDXScope(Layout)
|
💫 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
|
|
|
|
|
|
|
export const pageQuery = graphql`
|
|
|
|
query($slug: String!) {
|
|
|
|
site {
|
|
|
|
siteMetadata {
|
|
|
|
title
|
|
|
|
description
|
|
|
|
navigation {
|
|
|
|
text
|
|
|
|
url
|
|
|
|
}
|
2019-02-25 22:11:11 +03:00
|
|
|
docSearch {
|
|
|
|
apiKey
|
|
|
|
indexName
|
|
|
|
}
|
💫 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
|
|
|
}
|
|
|
|
}
|
|
|
|
file(fields: { slug: { eq: $slug } }) {
|
|
|
|
childMdx {
|
|
|
|
code {
|
|
|
|
scope
|
|
|
|
body
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|