Skip to content

Commit bd59514

Browse files
authoredSep 27, 2021
feat(gatsby-transformer-remark): Remove two obsolete options & improve README (#33295)
1 parent aec9981 commit bd59514

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed
 

‎packages/gatsby-transformer-remark/README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gatsby-transformer-remark
22

3-
Parses Markdown files using [Remark](http://remark.js.org/).
3+
Parses Markdown files using [remark](http://remark.js.org/).
44

55
## Install
66

@@ -32,21 +32,20 @@ plugins:
3232
- `options.gfm`
3333

3434
A full explanation of how to use markdown in Gatsby can be found here:
35-
[Creating a Blog with Gatsby](https://www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-with-gatsby/)
35+
[Adding Markdown Pages](https://www.gatsbyjs.com/docs/how-to/routing/adding-markdown-pages/)
3636

3737
There are many Gatsby Remark plugins which you can install to customize how Markdown is processed. Many of them are demoed at https://using-remark.gatsbyjs.org/. See also the [source code for using-remark](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-remark).
3838

3939
## Parsing algorithm
4040

4141
It recognizes files with the following extensions as Markdown:
4242

43-
- md
44-
- markdown
43+
- `md`
44+
- `markdown`
4545

4646
Each Markdown file is parsed into a node of type `MarkdownRemark`.
4747

48-
All frontmatter fields are converted into GraphQL fields. TODO link to docs on
49-
auto-inferring types/fields.
48+
All frontmatter fields are converted into GraphQL fields through [inference](https://www.gatsbyjs.com/docs/glossary/#inference).
5049

5150
This plugin adds additional fields to the `MarkdownRemark` GraphQL type
5251
including `html`, `excerpt`, `headings`, etc. Other Gatsby plugins can also add
@@ -93,9 +92,9 @@ Using the following GraphQL query you'll be able to get the table of contents
9392
}
9493
```
9594

96-
### Configuring the tableOfContents
95+
### Configuring the `tableOfContents`
9796

98-
By default, `absolute` is set to false, generating a relative path. If you'd like to generate an absolute path, pass `absolute: true`. In that case, be sure to pass the `pathToSlugField` parameter, often `fields.slug`, to create absolute URLs. **Note** that providing a non-existent field will cause the result to be null. To alter the default values for tableOfContents generation, include values for `heading` (string) and/or `maxDepth` (number 1 to 6) in GraphQL query. If a value for `heading` is given, the first heading that matches will be omitted and the toc is generated from the next heading of the same depth onwards. Value for `maxDepth` sets the maximum depth of the toc (i.e. if a maxDepth of 3 is set, only h1 to h3 headings will appear in the toc).
97+
By default, `absolute` is set to `false`, generating a relative path. If you'd like to generate an absolute path, pass `absolute: true`. In that case, be sure to pass the `pathToSlugField` parameter, often `fields.slug`, to create absolute URLs. **Note** that providing a non-existent field will cause the result to be `null`. To alter the default values for `tableOfContents` generation, include values for `heading` (string) and/or `maxDepth` (number 1 to 6) in GraphQL query. If a value for `heading` is given, the first heading that matches will be omitted and the ToC is generated from the next heading of the same depth onwards. Value for `maxDepth` sets the maximum depth of the toc (i.e. if a maxDepth of 3 is set, only h1 to h3 headings will appear in the toc).
9998

10099
```graphql
101100
{
@@ -119,7 +118,7 @@ By default, `absolute` is set to false, generating a relative path. If you'd lik
119118
}
120119
```
121120

122-
To pass default options to the plugin generating the tableOfContents, configure it in gatsby-config.js as shown below. The options shown below are the defaults used by the plugin.
121+
To pass default options to the plugin generating the `tableOfContents`, configure it in `gatsby-config.js` as shown below. The options shown below are the defaults used by the plugin.
123122

124123
```javascript
125124
// In your gatsby-config.js
@@ -171,7 +170,7 @@ By default, Gatsby will return excerpts as plain text. This might be useful for
171170
}
172171
```
173172

174-
It's also possible to ask Gatsby to return excerpts formatted as HTML. You might use this if you have a blog post whose excerpt contains markdown content--e.g. header, link, etc.--and you want these links to render as HTML.
173+
It's also possible to ask Gatsby to return excerpts formatted as HTML. You might use this if you have a blog post whose excerpt contains markdown content -- e.g. header, link, etc. -- and you want these links to render as HTML.
175174

176175
```graphql
177176
{
@@ -199,9 +198,9 @@ You can also get excerpts in Markdown format.
199198
}
200199
```
201200

202-
## gray-matter options
201+
## `gray-matter` options
203202

204-
`gatsby-transformer-remark` uses [gray-matter](https://github.com/jonschlinkert/gray-matter) to parse markdown frontmatter, so you can specify any of the options mentioned [here](https://github.com/jonschlinkert/gray-matter#options) in the `gatsby-config.js` file.
203+
`gatsby-transformer-remark` uses [gray-matter](https://github.com/jonschlinkert/gray-matter) to parse Markdown frontmatter, so you can specify any of the options mentioned [here](https://github.com/jonschlinkert/gray-matter#options) in the `gatsby-config.js` file.
205204

206205
### Example: Excerpts
207206

‎packages/gatsby-transformer-remark/src/gatsby-node.js

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`)
99

1010
exports.pluginOptionsSchema = function ({ Joi }) {
1111
return Joi.object({
12-
// Options `commonmark` and `pedantic` have no effect since gatsby-transformer-remark@4.0.0
13-
// TODO: remove in v5
14-
commonmark: Joi.any(),
15-
pedantic: Joi.any(),
1612
footnotes: Joi.boolean().description(
1713
`Activates Footnotes mode (default: true)`
1814
),

0 commit comments

Comments
 (0)
Please sign in to comment.