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
A full explanation of how to use markdown in Gatsby can be found here: [Adding Markdown Pages](https://www.gatsbyjs.com/docs/how-to/routing/adding-markdown-pages/)
56
+
57
+
There are many `gatsby-remark-*` plugins which you can install to customize how Markdown is processed. Check out the [source code for using-remark](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-remark) as an example.
58
+
59
+
### `gray-matter` options
60
+
61
+
`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 [in its README](https://github.com/jonschlinkert/gray-matter#options) in the `options` key of the plugin.
36
62
37
-
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).
63
+
**Example: Excerpts**
64
+
65
+
If you don't want to use `pruneLength` for excerpts but a custom separator, you can specify an `excerpt_separator`:
66
+
67
+
```js:title=gatsby-config.js
68
+
module.exports= {
69
+
plugins: [
70
+
{
71
+
resolve:`gatsby-transformer-remark`,
72
+
options: {
73
+
excerpt_separator:`<!-- end -->`
74
+
}
75
+
},
76
+
],
77
+
}
78
+
```
38
79
39
80
## Parsing algorithm
40
81
@@ -120,19 +161,20 @@ By default, `absolute` is set to `false`, generating a relative path. If you'd l
120
161
121
162
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.
122
163
123
-
```javascript
124
-
// In your gatsby-config.js
125
-
plugins: [
126
-
{
127
-
resolve:`gatsby-transformer-remark`,
128
-
options: {
129
-
tableOfContents: {
130
-
heading:null,
131
-
maxDepth:6,
164
+
```js:title=gatsby-config.js
165
+
module.exports= {
166
+
plugins: [
167
+
{
168
+
resolve:`gatsby-transformer-remark`,
169
+
options: {
170
+
tableOfContents: {
171
+
heading:null,
172
+
maxDepth:6,
173
+
},
132
174
},
133
175
},
134
-
},
135
-
]
176
+
],
177
+
}
136
178
```
137
179
138
180
### Excerpts
@@ -198,23 +240,6 @@ You can also get excerpts in Markdown format.
198
240
}
199
241
```
200
242
201
-
## `gray-matter` options
202
-
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.
204
-
205
-
### Example: Excerpts
206
-
207
-
If you don't want to use `pruneLength` for excerpts but a custom separator, you can specify an `excerpt_separator` in the `gatsby-config.js` file:
208
-
209
-
```javascript
210
-
{
211
-
"resolve":`gatsby-transformer-remark`,
212
-
"options": {
213
-
"excerpt_separator":`<!-- end -->`
214
-
}
215
-
}
216
-
```
217
-
218
243
Any file that does not have the given `excerpt_separator` will fall back to the default pruning method.
219
244
220
245
## Troubleshooting
@@ -237,14 +262,18 @@ If that is the case, you can set `truncate` option on `excerpt` field, like:
237
262
238
263
If your Markdown file contains HTML, `excerpt` will not return a value.
239
264
240
-
In that case, you can set an `excerpt_separator` in the `gatsby-config.js` file:
265
+
In that case, you can set an `excerpt_separator` in the `gatsby-config`:
`JS frontmatter engine is enabled in gatsby-transformer-remark (via jsFrontmatterEngine: true). This can cause a security risk, see https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-7ch4-rr99-cqcw. If you are not relying on this feature we strongly suggest disabling it via the "jsFrontmatterEngine: false" plugin option. If you rely on this feature make sure to properly secure or sanitize your content source.`
41
+
)
42
+
}
43
+
returnvalue
44
+
}
45
+
46
+
constjs=()=>{
47
+
if(!warnedAboutJSFrontmatterEngine){
48
+
console.warn(
49
+
`You have frontmatter declared with "---js" or "---javascript" that is not parsed by default to mitigate a security risk (see https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-7ch4-rr99-cqcw). If you require this feature it can be enabled by setting "jsFrontmatterEngine: true" in the plugin options of gatsby-transformer-remark.`
50
+
)
51
+
warnedAboutJSFrontmatterEngine=true
52
+
}
53
+
// we still have to return a frontmatter, so we just stub it with empty object
0 commit comments