Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gatsby-theme-docz

doczjs4.9kMIT2.4.0

Gatsby theme created to use Docz

gatsby, gatsby-theme, docz

readme

gatsby-theme-docz

The official Gatsby theme for Docz.

Installation

yarn add gatsby gatsby-theme-docz react react-dom

Usage

// gatsby-config.js
module.exports = {
  plugins: ['gatsby-theme-docz'],
}

Configuration

Set your config by using doczrc.js file (see all available) or if you want to set some defaults for your theme, use options on plugin definition:

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-theme-docz',
      options: {
        /* your custom options */
      },
    },
  ],
}

Dark Mode

To set the dark version as default, just set your doczrc.js like that:

// doczrc.js
export default {
  themeConfig: {
    mode: 'dark',
  },
}

Customizing components

Components shadowing is one of the best things included in the new Gatsby theme feature, with it is possible to replace theme files just by creating your own file following a file naming convention.

Example: If you're using our gatsby-theme-docz which has a Header component located at src/components/Header/index.js you can override the component by creating src/gatsby-theme-docz/components/Header/index.js. Cool right?

So, now that you know about how component shadowing works on Gatsby themes, if you don't want to override the entire <Header> component but just change your logo inside it, your can shadow the <Logo> component used in the header just by creating your own at src/gatsby-theme-docz/components/Logo/index.js

// src/gatsby-theme-docz/components/Logo/index.js
import React from 'react'
import logo from './logo.svg'

export const Logo = () => <img src={logo} alt="That's my logo" />

Easy, right?

Creating your own Docz theme

One of the coolest thing of Docz is that you can create your own theme if you want from scratch and use all benefits of it. The oldest way to acomplish that is by using the theme property inside the doczrc.js file. Now, if you want to create your own theme, just create a file located at src/gatsby-theme-docz/index.js

import React from 'react'
import { theme, useConfig, ComponentsProvider } from 'docz'
import { ThemeProvider } from '@emotion/react'
import baseComponents from 'gatsby-theme-docz/src/components'

import { Menu } from './MyBeautifulMenu'

const componentsMap = {
  ...baseComponents,
  /* your custom components */,
}

const Theme = ({ children }) => {
  const config = useConfig()
  return (
    <ThemeProvider theme={config}>
      <Menu />
      <ComponentsProvider components={baseComponents}>
        {children}
      </ComponentsProvider>
    </ThemeProvider>
  )
}

const themeConfig = {
  colors: {
    primary: 'tomato',
    secondary: 'khaki',
    gray: 'lightslategray',
  },
}

export default theme(themeConfig)(Theme)

Wrapping the entire app

Sometime you need to wrap your entire application in order to add some Provider or just to load some script. You can do this easily inside our theme by creating a file located at src/gatsby-theme-docz/wrapper.js

// src/gatsby-theme-docz/index.js
import React from 'react'

export default ({ children }) => (
  <div>
    <h1>My custom wrapper</h1>
    {children}
  </div>
)

Theme UI integrated

As default theme system we are using the Theme-UI, it's a library for build consistent, themeable React apps based on constraint-based design principles.

You can modify our based theme creating your own style, combining these modifications with the component shadowing and creating a totally different documentation.

Check our base theme object to see the properties.

To create your own theme definition use the doczrc.js and set your properties in the themeConfig like that:

// doczrc.js
export default {
  themeConfig: {
    colors: {
      header: {
        bg: 'tomato',
      },
    },
  },
}

Or, to create your own theme it's easy, just create this file in the root of your project: src/gatsby-theme-docz/theme/index.js.

import baseTheme from 'gatsby-theme-docz/src/theme'
import { merge } from 'lodash/fp'

export default merge(baseTheme, {
  colors: {
    header: {
      bg: 'tomato',
    },
  },
})

Changing code highlight

Both code highlights shortcodes and the <Playground> component are using prism-react-renderer to highlight the code. If you want to modify and use another PrismJS theme, you can do that just passing a prismTheme property for your theme.

// doczrc.js
import myCustomPrismTheme from './my-prism-theme'

export default {
  themeConfig: {
    prismTheme: myCustomPrismTheme,
  },
}

Or you want to have different themes for light and dark color mode, you can change the prism default property like that:

// doczrc.js
import customLightTheme from './my-light-theme'
import customDarkTheme from './my-dark-theme'

export default {
  themeConfig: {
    prism: {
      light: customLightTheme,
      dark: customDarkTheme,
    },
  },
}

Adding component shortcodes

You can add shortcodes to your docs site which can be used throughout your docs pages by extending the components passed to MDXProvider. You can do this by using component shadowing and creating the following file in the root of your project: src/gatsby-theme-docz/components/index.js.

Example components.js

import baseComponents from 'gatsby-theme-documentation/src/components'
import MyCustomH1 from '../components/my-custom-h1'

export default {
  ...baseComponents,
  h1: MyCustomH1,
}

Getting data

Using our Gatsby Theme you can enjoy all our hooks to get data for your pages and also get data from Gatsby. So, you can create isolated pages on Gatsby using gatsby pages and get data from Docz or maybe pass data for your Docz documents using source from gatsby.

Imagine, that you have your home page inside /pages and you want to show all documents parsed from Docz. You can easy get this by doing:

import React from 'react'
import { useDocs } from 'docz'

const Home = () => {
  const docs = useDocs()
  return <div>{/* my coolest home */}</div>
}

export default Home

Or you can have a mdx document inside Docz that has data from Gatsby too:

---
name: MyDoc
---

import { MyComponentWithSomeData } from './my-component-with-data'

<MyComponentWithSomeData />

Cool right?

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.4.0 (2022-02-11)

Bug Fixes

Features

  • gatsby-theme-docz: configure SEO information from md/mdx files (#1477) (24bb600)
  • gatsby-theme-docz: no reload on relative links (#1482) (ff7211c)

2.3.3-alpha.0 (2021-09-10)

Bug Fixes

Features

  • gatsby-theme-docz: configure SEO information from md/mdx files (#1477) (24bb600)
  • gatsby-theme-docz: no reload on relative links (#1482) (ff7211c)

2.3.1 (2020-04-05)

Note: Version bump only for package gatsby-theme-docz

2.3.1-alpha.0 (2020-04-05)

Bug Fixes

  • gatsby-theme-docz: fix theme components customization bug (a9384b0)

2.3.0 (2020-04-02)

Note: Version bump only for package gatsby-theme-docz

2.3.0-alpha.14 (2020-03-31)

Bug Fixes

  • gatsby-theme-docz: add pre-wrap to error (#1406) (ca6b02d)
  • gatsby-theme-docz: content overflowing issue (#1437) (56f4cb8)

Features

  • gatsby-theme-docz: include MDX transclusion support (#1436) (435001a)

2.3.0-alpha.13 (2020-02-13)

Bug Fixes

  • gatsby-theme-docz: flex component aligmItems -> alignItems (#1391) (b80524f)

2.3.0-alpha.12 (2020-02-12)

Bug Fixes

  • gatsby-theme-docz: use sx instead of style prop in Playgro… (#1389) (98f3311)

2.3.0-alpha.11 (2020-02-07)

Features

  • gatsby-theme-docz: create MainContainer component (#1381) (e8d1c04)

2.3.0-alpha.8 (2020-02-06)

Note: Version bump only for package gatsby-theme-docz

2.3.0-alpha.7 (2020-02-04)

Bug Fixes

  • gatsby-theme-docz: fix playground react-resize-detector usage (#1350) (f0baf67)
  • gatsby-theme-docz: removed unused gatsby-plugin-manifest (#1368) (44edc68)

Features

  • add the ability to hide a document from the menu (#1354) (95b0d7f)

2.3.0-alpha.5 (2019-12-17)

Bug Fixes

  • gatsby-theme-docz: src -> gatsbyRoot for file system source (71dd572)

2.3.0-alpha.4 (2019-12-16)

Bug Fixes

  • gatsby-theme-docz: make Props isToggle work again (#1326) (4921ef5)
  • update dev-env dependencies (e1b185f)

2.3.0-alpha.3 (2019-12-16)

Bug Fixes

  • gatsby-theme-docz: fix preview padding (ebebd1c), closes #1325

2.3.0-alpha.2 (2019-12-14)

Note: Version bump only for package gatsby-theme-docz

2.3.0-alpha.1 (2019-12-13)

Note: Version bump only for package gatsby-theme-docz

2.2.1-alpha.0 (2019-12-11)

Bug Fixes

  • gatsby-theme-docz: fix mdx components theming from config (3a9bdb7), closes #1309

2.2.0 (2019-12-11)

Note: Version bump only for package gatsby-theme-docz

2.2.0-alpha.8 (2019-12-06)

Features

  • gatsby-theme-docz: add optional iframe for preview and ed… (#1305) (9c5082e), closes #1306

2.2.0-alpha.7 (2019-12-03)

Bug Fixes

  • gatsby-theme-docz: fix infinite renders in playground on hot reload (3451fd1), closes #1299

2.2.0-alpha.6 (2019-12-03)

Bug Fixes

  • gatsby-theme-docz: fix horizontal code overflow (a0b7823)

2.2.0-alpha.5 (2019-12-01)

Bug Fixes

  • gatsby-theme-docz: fix tsx parsing in code blocks (b321ff8)

2.2.0-alpha.4 (2019-11-30)

Features

  • gatsby-theme-docz: add showMarkdownEditButton flag (8fd04e8), closes #1291

2.2.0-alpha.1 (2019-11-28)

Bug Fixes

  • gatsby-theme-docz: remove typo from the theme styles (a25da88)

2.2.0-alpha.0 (2019-11-28)

Bug Fixes

  • gatsby-theme-docz: set gatsby root from doczrc src (e6b1521)

2.1.0 (2019-11-27)

Bug Fixes

  • gatsby-theme-docz: allow empty ts prop defaultValue (2512aa1)
  • gatsby-theme-docz: fix min-height (34fc31f)

Features

  • gatsby-theme-docz: use mdxExtensions from config (7d405c5)

Bug Fixes

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: expose gatsby actions to plugin (019eb9b)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

2.0.0-rc.33 (2019-09-04)

Note: Version bump only for package gatsby-theme-docz

2.0.0-rc.32 (2019-09-04)

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: expose gatsby actions to plugin (66546a4)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

2.0.0-rc.31 (2019-09-03)

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

<<<<<<< HEAD

2.0.0-rc.28 (2019-09-02)

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

=======

2.0.0-rc.29 (2019-09-03)

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

2.0.0-rc.28 (2019-09-03)

v2.0.0-rc.29

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: fix style differences between dev and build (9cb5237)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

2.0.0-rc.27 (2019-09-02)

Bug Fixes

  • docz-core: use react from parent directory (#1053) (b55b786)
  • gatsby-theme-docz: fix style differences between dev and build (45b7767)
  • gatsby-theme-docz: replace iframe in playground with div #984 #1035 (4214180)

2.0.0-rc.9 (2019-08-30)

Note: Version bump only for package gatsby-theme-docz

2.0.0-rc.6 (2019-08-29)

Bug Fixes

2.0.0-rc.2 (2019-08-28)

Bug Fixes

  • gatsby-theme-docz: add missing source sans pro font (#991) (51240df)
  • gatsby-theme-docz: replace fragment tag to the short syntax (#992) (044f351)

2.0.0-rc.1 (2019-07-18)

Bug Fixes

  • bump version (a346b59)
  • resizable props import (2926896)
  • gatsby-theme-docz: resizable import (3916265)
  • on create webpack plugin hook (56e974a)
  • remove react & react-dom from dependencies #924 (faf4288)
  • some typescript adjustments (4ba6eaf)
  • gatsby-theme-docz: prisms theme by themeConfig (c0b5c34)
  • eslint configs (280981f)
  • gatsby-theme-docz: entry not in context (e582221)

Features

  • gatsby-theme-docz: add blockquote styles (b9f11a1)
  • gatsby-theme-docz: add custom logo support (dec4b2b)
  • gatsby-theme-docz: add iframe and re-resizable on playground (6922717)
  • gatsby-theme-docz: add new Pre component (a6be6a1)
  • gatsby-theme-docz: add new Props component (8eb780d)
  • gatsby-theme-docz: add showLiveError on Playground (e593897)
  • gatsby-theme-docz: add some improvements (03d9fec)
  • gatsby-theme-docz: improve code highlight (d265444)
  • gatsby-theme-docz: improve documentation (80b35f8)
  • a lot of improvements (64f75da)
  • adapt core plugins to gatsby hooks (4caa47a)
  • add main package improvements (8c8005d)
  • add markdown parsing on props description (1087539)
  • add new Playground component (7bf03b2)
  • add new theme sidebar (a01d100)
  • add typescript support (need fix) (13947f9)
  • docz running using gatsby under the hood (10ffd48)
  • dynamic src and root path (c071556)
  • some playground improvements (afa00df)

1.2.0 (2019-05-08)

Note: Version bump only for package gatsby-theme-docz

1.1.0 (2019-05-01)

Bug Fixes

  • docz-core: prevent watch in production (d673262)

1.0.4 (2019-04-18)

Note: Version bump only for package gatsby-theme-docz

1.0.3 (2019-04-15)

Note: Version bump only for package gatsby-theme-docz

1.0.2 (2019-04-15)

Note: Version bump only for package gatsby-theme-docz

1.0.1 (2019-04-14)

Note: Version bump only for package gatsby-theme-docz

1.0.0 (2019-04-11)

Bug Fixes

  • docz: crash using suspense (315f7ad)

1.0.0-rc.4 (2019-03-29)

Note: Version bump only for package gatsby-theme-docz

1.0.0-rc.3 (2019-03-21)

Bug Fixes

  • gatsby-theme-docz: menu field on entry source node (05457f2)

1.0.0-beta.0 (2019-03-19)

Note: Version bump only for package gatsby-theme-docz

1.0.0-alpha.1 (2019-03-19)

Bug Fixes

1.0.0-alpha.0 (2019-03-19)

Bug Fixes

  • gatsby-theme-docz: add null fields for entries (b0409a8)
  • gatsby-theme-docz: add specific nodes for entries (26f7f90)
  • gatsby-theme-docz: add ssr support for styled-components (b490010)
  • gatsby-theme-docz: check data before access (8f8ed12)
  • gatsby-theme-docz: check entries before find on it (8565128)
  • gatsby-theme-docz: create pages hook (2f5765e)
  • gatsby-theme-docz: hot reload (bf4e440)
  • gatsby-theme-docz: readme typo (9e3314a)
  • gatsby-theme-docz: throws false for json stringify (289ca75)
  • define right internal dependencies version (30a91b4)
  • gatsby theme fixes (dcc5f19)
  • gatsby-theme-docz: use options from gatsby-config (#665) (c694bdf)
  • some general adjustments (0c61f64)
  • gatsby-theme-docz: use createPages instead of createPagesStatefully (37b73c6)

Features

  • gatsby-theme-docz: add custom theme support (fdfddcb)
  • gatsby-theme-docz: add wrapper support (a99d62f)
  • add initial gatsby integration (#630) (70d40cc), closes #609
  • add playground component (cde6511)