You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: src/docs/documentation/customizing/add-favicon-and-metadata.mdx
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,33 +5,33 @@ parent: Documentation
5
5
menu: Customizing
6
6
---
7
7
8
-
To add a favicon and metadata to your generated gatsby site, follow this quick guide
8
+
# Add favicon and metadata
9
9
10
-
Add [`react-helmet`](https://github.com/nfl/react-helmet)along with [`gatsby-plugin-react-helmet`](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-react-helmet)
10
+
Adding metadata to your site is done by configuring Gatsby in combination with [`react-helmet`](https://github.com/nfl/react-helmet)[**source @ gatsby**](https://www.gatsbyjs.org/docs/add-page-metadata/).
11
11
12
-
[How do I add react-helmet to my docz app ?](https://www.gatsbyjs.org/docs/add-page-metadata/)
13
12
14
-
Once you've added react-helmet you can shadow the `src/wrapper.js` theme component to add metadata
13
+
### Shadowing the Wrapper-component
15
14
16
-
so you would create a file : `src/gatsby-theme-docz/wrapper.js` (path is important) and inside it :
15
+
The metadata is set up in a file called `wrapper.js` which lives in docz theme package: `gatsby-theme-docz`. To override it we need to [Shadow the component](https://www.gatsbyjs.org/blog/2019-04-29-component-shadowing/), which means that we need to create a copy of the file with the "same" file path and name in our own `src`-directory.
17
16
17
+
1. Create a file called `wrapper.js` in `src/gatsby-theme-docz`. Then path is important.
18
+
2. Paste the following content and edit it to your liking
18
19
```js
19
20
import*asReactfrom'react'
20
21
import { Helmet } from'react-helmet'
21
22
22
23
constWrapper= ({ children }) =><React.Fragment>
23
24
<Helmet>
24
25
<meta charSet="utf-8"/>
25
-
<title>My Title</title>
26
-
<link rel="icon"
27
-
type="image/png"
28
-
href="http://example.com/myicon.png"
29
-
>
26
+
<title>My Shadow!</title>
27
+
<link rel="icon"
28
+
type="image/png"
29
+
href="http://example.com/myicon.png"
30
+
/>
30
31
</Helmet>
31
32
{children}
32
33
</React.Fragment>
33
34
exportdefaultWrapper
34
-
35
35
```
36
36
37
-
And that should do it 👍.
37
+
If you rebuild your site now it should use this component as a wrapper instead of the themes component.
All components that comes with the standard theme `gatsby-theme-docz` can be [**shadowed**](https://www.gatsbyjs.org/blog/2019-04-29-component-shadowing/). This means that you can supply your own component that will shadow/override the themes component. This is done by placing a component with the same name as the themes component in the "same filepath" as the original component.
11
+
12
+
For example if you want to shadow the `Logo`-component you would have to have the following structure in your folder:
13
+
14
+
```
15
+
your-site
16
+
└── src
17
+
└── gatsby-theme-docz
18
+
└── components
19
+
└── Logo
20
+
└──index.js
21
+
```
22
+
23
+
If it has the matching folder structure and name the theme component will be shadowed and you can freely edit.
As you see, `<Playground>` rendered your component in a blank state, and right below, displayed the code used to.
38
-
This can be very useful to test and develop your components in a good environment while you document it.
38
+
This can be very useful to test and develop your components in a good environment while you document it. The code below the component is also editable and the changes you make to that code will reflect live in the component above!
39
39
40
40
## Component Props
41
41
@@ -67,8 +67,44 @@ import { Button } from './'
67
67
</Playground>
68
68
```
69
69
70
-
And now you have a list of properties:
70
+
The button that will display the props must have some annotation on the props. For non flow or typescript users this can be achieved with [`prop-types`](https://www.npmjs.com/package/prop-types)
71
+
72
+
```jsx
73
+
importReactfrom'react'
74
+
importtfrom'prop-types'
75
+
76
+
constButton= ({ children, kind }) => {
77
+
// Do something nice with the kind prop, like add a class with it
78
+
return<button>{children}</button>
79
+
}
80
+
81
+
Button.propTypes= {
82
+
/**
83
+
* This is a pretty good description for this prop.
You can see more about our built-in components on [Components API](/docs/components-api).
97
+
The same can be achieved in typescript by adding comments to the props interface of your component:
98
+
99
+
```jsx
100
+
importReactfrom'react'
101
+
102
+
interface ButtonProps {
103
+
/**
104
+
* This is a pretty good description for this prop.
105
+
*/
106
+
kind:'primary'|'secondary'|'cancel'|'dark'|'gray'
107
+
}
108
+
```
109
+
110
+
You can read more in depth about our built-in components on [**Components API**](/docs/components-api). If you are more interested in learning more about the MDX-pages you could head on to [**Document Settings**](/docs/document-settings)
Copy file name to clipboardExpand all lines: src/docs/documentation/general/deploying-your-docs.mdx
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Now that you know about writing your docs, let's talk about how you can build an
11
11
The first thing that you need to do is run the build script created in your `package.json`:
12
12
13
13
```bash
14
-
$ yarn build
14
+
$ yarn docz:build
15
15
```
16
16
17
17
If everything goes well, this command will generate all static files for you in the `.docz/dist` folder and you will see something like this in your terminal:
@@ -31,6 +31,17 @@ export default {
31
31
}
32
32
```
33
33
34
+
## Changing base folder
35
+
36
+
If you are using something like [GitHub Pages](https://pages.github.com/) chances are that you are not deploying your site directly under the root of your user. For example if you have a `docz`-repository on your GitHub the URL for deploying that repository will be `https://your-username.github.io/docz`. You can specify in which subdirectory your files will be deployed with the `base`-property of `doczrc.js`.
37
+
38
+
```js
39
+
// doczrc.js
40
+
exportdefault {
41
+
base:'/docz',
42
+
}
43
+
```
44
+
34
45
## Using Netlify
35
46
36
47
If you understand nothing about deploys, we highly recommend that you use the service we're using to host this website that you're seeing, called [Netlify](http://netlify.com/). Netlify is a really fantastic and easy tool that allows you to deploy your application in an automatic way by running the deploy on every push from a branch in seconds.
Copy file name to clipboardExpand all lines: src/docs/documentation/general/document-settings.mdx
+5-11Lines changed: 5 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ menu: General
10
10
Document settings can be something simple, but powerful. They should be defined in the top of the `.mdx`
11
11
using yaml and can be used to change whatever you want by passing this config to your theme.
12
12
13
-
By default the document has just three properties that can't be overrided:
13
+
By default the document has **three** properties that can't be overriden:
14
14
15
15
```markdown
16
16
---
@@ -20,9 +20,7 @@ menu: Documents
20
20
---
21
21
```
22
22
23
-
These properties are self-explanatory, but here is their definition:
24
-
25
-
-`name` Define the name of your component.
23
+
-`name` Define the name of your component, the title of the page
26
24
-`route *(optional)*` Define the route of your component.
27
25
28
26
>If you don't pass any here, we'll create a slug getting the filepath of your file as route.
@@ -31,18 +29,14 @@ These properties are self-explanatory, but here is their definition:
31
29
32
30
## Custom properties
33
31
34
-
With just this properties perhaps you couldn't do many customizations.
35
-
But, all documents can have arbitrary properties and you can use them to built your theme.
36
-
37
-
Example: you can define a property called `fullpage` to define whether your document is a page with `100%` width or not:
32
+
The built in properties are for docz but docz is exstensible and you can create your own themes where you could have different needs and need different properties. Custom properties can be set in the document settings and they will automatically be parsed.
38
33
34
+
For example you can define a property called `fullpage` to define whether your document is a page with `100%` width or not:
39
35
```
40
36
---
41
37
name: My Document
42
38
fullpage: true
43
39
---
44
40
```
45
41
46
-
Now when you're creating your theme you can use this property to define inside your page component if shows a container of not.
47
-
48
-
This is very powerful and gives you flexibility when developing your own themes.
42
+
When you later on are creating a theme these settings are passed to your theme components which you can read more about under [**Creating your themes: Using documents settings**](/docz/creating-your-themes#using-documents-settings)
Most configuration is from version 2 handled by Gatsby, and CSS preprocessing is no exception. Gatsby uses a range of [**Plugins**](https://www.gatsbyjs.org/plugins/) to handle things like `sass`, `less` and `postcss`. Gatsby supports CSS Modules out of the box.
11
+
12
+
These plugins are added by adding a `gatsby-config.js` in your project root or modifying an existing one. For example if you want to add support for `sass` you would do the following:
13
+
14
+
1. Install [`node-sass`](https://github.com/sass/node-sass) and [`gatsby-plugin-sass`](https://www.gatsbyjs.org/packages/gatsby-plugin-sass/)
15
+
```bash
16
+
# npm
17
+
npm install --save node-sass gatsby-plugin-sass
18
+
19
+
# yarn
20
+
yarn add node-sass gatsby-plugin-sass
21
+
```
22
+
23
+
2. Add the plugin to your `gatsby-config.js`
24
+
```js
25
+
//gatsby-config.js
26
+
module.exports= {
27
+
plugins: ['gatsby-plugin-sass']
28
+
}
29
+
```
30
+
You should now be able to use `sass` in your components!
Copy file name to clipboardExpand all lines: src/docs/documentation/general/usage-with-typescript.mdx
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ menu: General
7
7
8
8
# Using docz with Typescript
9
9
10
-
To use docz with TypeScript codebase you need to add `typescript: true` to your doczrc.js
10
+
To use docz with TypeScript codebase you need to add `typescript: true` to your `doczrc.js`, the rest will be setup by _docz_.
11
11
12
12
```js
13
13
exportdefault {
@@ -17,11 +17,20 @@ export default {
17
17
18
18
# Documenting Props in TypeScript
19
19
20
-
`docz` exports a Props component that takes in a component and generates a table of its props types, descriptions and default values.
20
+
As mentioned in [**Built-in components**](/docs/built-in-components) the `<Props/>`-component is used to automatically document your components props assuming you have the correct comments on your components like below.
21
21
22
-
Make sure to reference the full path to the module you're documenting in your MDX file
22
+
```js
23
+
interface ButtonProps {
24
+
/**
25
+
* A description of the prop that you seem fit :)
26
+
*/
27
+
kind:'primary'|'secondary'|'cancel'|'dark'|'gray'
28
+
}
29
+
```
23
30
24
-
```mdx
31
+
The typescript parser can be a bit fussy sometimes (and we are working on it) so if your typescript-files are not being found you may have to write out the full path with the file ending. If this doesn't do the trick you can try checking if using `default` exports or `named` exports are the problem.
32
+
33
+
```js
25
34
import { Props } from'docz'
26
35
importButtonfrom'./Button.tsx'
27
36
@@ -30,3 +39,14 @@ import Button from './Button.tsx'
30
39
31
40
```
32
41
42
+
# Advanced configuration
43
+
44
+
If you have particular needs or need to control exactly which files are being picked up or if you want to tap into the parser that creates the documentation there are two properties on the `doczrc.js` that you can use: `filterComponents` and `docgenConfig` (some use cases explained [here](https://github.com/doczjs/docz/issues/827))
45
+
46
+
```js
47
+
exportdefault {
48
+
filterComponents: (files) =>
49
+
//This overrides the default filtering of components
Copy file name to clipboardExpand all lines: src/docs/documentation/general/writing-mdx.mdx
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ More details about MDX in the [Official website.](https://mdxjs.com/)
15
15
## Working with components
16
16
17
17
For now, you only need to know that with MDX you can use your components inside markdown.
18
-
But how? Let's take a look at how we can improve our `.mdx` created before by importing and using a component inside it:
18
+
But how? Let's take a look at how we can improve our `.mdx` created before by importing and using a component inside it. The example below assumes we have a exported component named `Button` in a file named `Button.jsx`/`Button.tsx` located in the same folder as the `.mdx`-file we are editing.
19
19
20
20
```markdown
21
21
---
@@ -35,6 +35,8 @@ And, if you really have a `Button` component to import, you'll see something lik
With MDX you can mix _React Components_ or _html-elements_ with regular markdown allowing you to either document your own components _or_ creating helper components that makes documentation easier. **Docz** comes with some prebuilt helper components which will help you document components faster, these are covered in [**Built-in components**](/docs/built-ins-components).
39
+
38
40
> ### Note
39
41
>
40
42
> So far Docz only works with React components. But stay calm, we are working to bring Preact, Vue and some others libraries to Docz!
0 commit comments