💫 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 18:31:19 +00:00
|
|
|
import { navigate } from 'gatsby'
|
|
|
|
|
|
|
|
import './src/styles/layout.sass'
|
|
|
|
import Juniper from './src/components/juniper'
|
2019-02-26 15:51:22 +00:00
|
|
|
import 'intersection-observer'
|
💫 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 18:31:19 +00:00
|
|
|
|
|
|
|
// Workaround to rewrite anchor links
|
|
|
|
const clientSideRewrites = {
|
|
|
|
'/usage/linguistic-features/#rule-based-matching': '/usage/rule-based-matching',
|
|
|
|
}
|
|
|
|
|
|
|
|
/* eslint-disable */
|
|
|
|
import HKGroteskSemiBoldWOFF from './src/fonts/hkgrotesk-semibold.woff'
|
|
|
|
import HKGroteskSemiBoldWOFF2 from './src/fonts/hkgrotesk-semibold.woff2'
|
|
|
|
import HKGroteskSemiBoldItalicWOFF from './src/fonts/hkgrotesk-semibolditalic.woff'
|
|
|
|
import HKGroteskSemiBoldItalicWOFF2 from './src/fonts/hkgrotesk-semibolditalic.woff2'
|
|
|
|
import HKGroteskBoldWOFF from './src/fonts/hkgrotesk-bold.woff'
|
|
|
|
import HKGroteskBoldWOFF2 from './src/fonts/hkgrotesk-bold.woff2'
|
|
|
|
import HKGroteskBoldItalicWOFF from './src/fonts/hkgrotesk-bolditalic.woff'
|
|
|
|
import HKGroteskBoldItalicWOFF2 from './src/fonts/hkgrotesk-bolditalic.woff2'
|
|
|
|
/* eslint-enable */
|
|
|
|
|
|
|
|
export const onInitialClientRender = () => {
|
|
|
|
// Importing Juniper in the component currently causes various problems
|
|
|
|
// because of the global window reference in its dependencies. So this
|
|
|
|
// is kinda hacky at the moment.
|
|
|
|
window.Juniper = Juniper
|
|
|
|
}
|
|
|
|
|
|
|
|
export const onRouteUpdate = ({ location }) => {
|
|
|
|
window.dispatchEvent(new Event('resize')) // for progress
|
|
|
|
window.dispatchEvent(new Event('scroll')) // for progress
|
|
|
|
if (location.hash) {
|
|
|
|
// Client-side rewrites
|
|
|
|
const rewrite = clientSideRewrites[location.pathname + location.hash]
|
|
|
|
if (rewrite) {
|
|
|
|
navigate(rewrite)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
const el = document.querySelector(`${location.hash}`)
|
|
|
|
if (el) {
|
|
|
|
// Navigate to targeted element
|
|
|
|
el.scrollIntoView()
|
|
|
|
// Force recomputing :target pseudo class with pushState/popState
|
|
|
|
window.location.hash = location.hash
|
|
|
|
}
|
|
|
|
}, 0)
|
|
|
|
}
|
|
|
|
}
|