-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gatsbyRemarkPlugins option (#146)
Co-authored-by: Jo茫o Pedro Schmitz <oi@joaopedro.cc>
- Loading branch information
1 parent
3768677
commit a4903ae
Showing
7 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@rocketseat/gatsby-theme-docs': minor | ||
'@rocketseat/gatsby-theme-docs-core': minor | ||
--- | ||
|
||
Add `gatsbyRemarkPlugins` option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
examples/gatsby-theme-docs/src/docs/usage/remark-plugins.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Remark plugins | ||
description: Learn how to use Remark plugins in Rocket Docs. | ||
--- | ||
|
||
To use a Remark plugin, you need to set the plugin name on this theme's `gatsbyRemarkPlugins` option. | ||
|
||
## Example usage | ||
|
||
Given that we want to use [Graphviz](https://graphviz.org/) in our Markdown files, we need to install the Remark plugin and add it on to `gatsbyRemarkPlugins` option on `gatsby.config.js`. | ||
|
||
```sh | ||
# Using Yarn: | ||
yarn add gatsby-remark-graphviz | ||
# Using NPM: | ||
npm i gatsby-remark-graphviz | ||
``` | ||
|
||
```js title=gatsby-config.js | ||
module.exports = { | ||
siteMetadata: { | ||
// ... | ||
}, | ||
plugins: [ | ||
{ | ||
resolve: `@rocketseat/gatsby-theme-docs`, | ||
options: { | ||
// ... | ||
gatsbyRemarkPlugins: [ | ||
{ | ||
`gatsby-remark-graphviz`, | ||
} | ||
] | ||
}, | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Using a custom Remark Transformer plugin | ||
|
||
If you use a local plugin, you must point to its location in the project through `require.resolve`. | ||
|
||
```js title=gatsby-config.js | ||
module.exports = { | ||
siteMetadata: { | ||
// ... | ||
}, | ||
plugins: [ | ||
{ | ||
resolve: `@rocketseat/gatsby-theme-docs`, | ||
options: { | ||
// ... | ||
gatsbyRemarkPlugins: [ | ||
{ | ||
`gatsby-remark-graphviz`, | ||
resolve: require.resolve(`./plugins/gatsby-remark-purple-headers`) | ||
} | ||
] | ||
}, | ||
} | ||
] | ||
} | ||
``` | ||
|
||
For more information on how to create a Remark Transformer plugin, please refer to the [Creating a Remark Transformer Plugin](https://www.gatsbyjs.com/tutorial/remark-plugin-tutorial/) document. |