diff --git a/core/docz-theme-default/src/components/ui/AsyncPlayground.tsx b/core/docz-theme-default/src/components/ui/AsyncPlayground.tsx deleted file mode 100644 index b04ff1824..000000000 --- a/core/docz-theme-default/src/components/ui/AsyncPlayground.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import * as React from 'react' - -const Playground = React.lazy(() => import('./Playground')) -export const AsyncPlayground: React.SFC = props => ( - - - -) diff --git a/core/docz-theme-default/src/components/ui/Playground/index.tsx b/core/docz-theme-default/src/components/ui/Playground/index.tsx index 8ce766661..1d8fde1de 100644 --- a/core/docz-theme-default/src/components/ui/Playground/index.tsx +++ b/core/docz-theme-default/src/components/ui/Playground/index.tsx @@ -100,7 +100,7 @@ export interface PlaygroundProps extends BasePlaygroundProps { showEditor?: boolean } -const Playground: SFC = ({ +export const Playground: SFC = ({ position, code: initialCode, codesandbox, @@ -287,5 +287,3 @@ const Playground: SFC = ({ ) } - -export default Playground diff --git a/core/docz-theme-default/src/components/ui/index.ts b/core/docz-theme-default/src/components/ui/index.ts index c5f275a62..46531798f 100644 --- a/core/docz-theme-default/src/components/ui/index.ts +++ b/core/docz-theme-default/src/components/ui/index.ts @@ -1,4 +1,4 @@ -import { AsyncPlayground } from './AsyncPlayground' +import { Playground } from './Playground' import { Blockquote } from './Blockquote' import { H1 } from './H1' import { H2 } from './H2' @@ -35,7 +35,7 @@ export const components = { ol: OrderedList, p: Paragraph, page: Page, - playground: AsyncPlayground, + playground: Playground, pre: Pre, props: Props, table: Table, diff --git a/core/docz/src/components/AsyncPlayground.tsx b/core/docz/src/components/AsyncPlayground.tsx new file mode 100644 index 000000000..8b6e5917b --- /dev/null +++ b/core/docz/src/components/AsyncPlayground.tsx @@ -0,0 +1,10 @@ +import * as React from 'react' +import loadable from '@loadable/component' + +const BasePlayground = loadable(() => import('./Playground')) +export const Playground: React.SFC = props => + typeof window !== 'undefined' ? ( + + + + ) : null diff --git a/core/docz/src/components/Playground.tsx b/core/docz/src/components/Playground.tsx index eec65cbd4..5ea5089bc 100644 --- a/core/docz/src/components/Playground.tsx +++ b/core/docz/src/components/Playground.tsx @@ -14,7 +14,7 @@ export interface PlaygroundProps { __codesandbox: string } -export const Playground: SFC = ({ +const Playground: SFC = ({ className, style, wrapper: Wrapper, @@ -40,3 +40,5 @@ export const Playground: SFC = ({ /> ) } + +export default Playground diff --git a/core/docz/src/index.ts b/core/docz/src/index.ts index f68614077..12a440330 100644 --- a/core/docz/src/index.ts +++ b/core/docz/src/index.ts @@ -1,6 +1,6 @@ +export { Playground } from './components/AsyncPlayground' export { AsyncRoute, loadRoute } from './components/AsyncRoute' export { Link, LinkProps } from './components/Link' -export { Playground } from './components/Playground' export { Props, PropsComponentProps } from './components/Props' export { Routes } from './components/Routes' diff --git a/core/gatsby-theme-docz/src/node/createPages.js b/core/gatsby-theme-docz/src/node/createPages.js index f6853ade8..57753f02c 100644 --- a/core/gatsby-theme-docz/src/node/createPages.js +++ b/core/gatsby-theme-docz/src/node/createPages.js @@ -16,7 +16,6 @@ const ENTRIES_QUERY = ` slug name menu - order headings { slug depth diff --git a/core/gatsby-theme-docz/src/node/sourceNodes.js b/core/gatsby-theme-docz/src/node/sourceNodes.js index 0024cf997..3108711a7 100644 --- a/core/gatsby-theme-docz/src/node/sourceNodes.js +++ b/core/gatsby-theme-docz/src/node/sourceNodes.js @@ -2,7 +2,6 @@ const crypto = require('crypto') const fs = require('fs-extra') const { Entries, DataServer, states } = require('docz-core') const { parseConfig } = require('../utils/parseConfig') -const { omit } = require('lodash/fp') const digest = str => crypto @@ -60,11 +59,11 @@ module.exports = async ({ actions, createNodeId }, opts) => { }) } - await createDbNode() - await createEntriesNode() - - dataServer.onStateChange(async () => { + const createNodes = async () => { await createDbNode() await createEntriesNode() - }) + } + + await createNodes() + dataServer.onStateChange(async () => createNodes()) } diff --git a/examples/gatsby/package.json b/examples/gatsby/package.json index 3f6f00834..193d3094f 100644 --- a/examples/gatsby/package.json +++ b/examples/gatsby/package.json @@ -10,6 +10,7 @@ "scripts": { "dev": "gatsby develop", "build": "gatsby build", + "serve": "gatsby serve", "format": "prettier --write \"src/**/*.js\"" }, "devDependencies": {