import React from 'react' import PropTypes from 'prop-types' import useOnlineStatus from '@rehooks/online-status' import classNames from 'classnames' // 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 { InlineCode } from '../components/inlineCode' import Alert from '../components/alert' import Search from '../components/search' import siteMetadata from '../../meta/site.json' import { nightly, legacy } from '../../meta/dynamicMeta.mjs' import { remarkComponents } from '../remark' const AlertSpace = ({ nightly, legacy }) => { const isOnline = useOnlineStatus() return ( <> {nightly && ( The page reflects{' '} spacy-nightly , not the latest stable version. )} {legacy && ( The page reflects an older version of spaCy, not the latest{' '} stable release. )} {!isOnline && ( But don't worry, your visited pages should be saved for you. )} ) } const navAlert = ( 💥 Out now: spaCy v3.6 ) class Layout extends React.Component { static defaultProps = { scope: {}, } static propTypes = { 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, searchExclude: PropTypes.bool, next: PropTypes.shape({ title: PropTypes.string.isRequired, slug: PropTypes.string.isRequired, }), }), children: PropTypes.node, } 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: { ...remarkComponents, ...props.scope } } } render() { const { location, children } = this.props const { title, section, sectionTitle, teaser, theme, searchExclude } = this.props const uiTheme = nightly ? 'nightly' : legacy ? 'legacy' : theme ?? 'blue' const bodyClass = classNames(`theme-${uiTheme}`, { 'search-exclude': !!searchExclude }) const isDocs = ['usage', 'models', 'api', 'styleguide'].includes(section) return (
} alert={nightly ? null : navAlert} > {isDocs ? ( {children} ) : section === 'universe' ? ( ) : (
{children}
)}
) } } export default Layout