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
Use graymatter excerpt in gatsby-transformer-remark (#2883)
* Check for graymatter excerpt
Checks to see if there is a gray-matter excerpt before returning a
pruned character count
* Fix test
Remove a variable that wasn't being used
* Create page to describe excerpts
* Update using-remark example
* Remove package-lock.json
* Remove console.log statements
* Update copy
Updates copy to be a bit more descriptive
* Update header for example page
* Begin stubbing out extend-node.js tests
Created a basic framework for creating a markdown node via the
onCreateNode function. This should be expanded to factor in the changes
that occur in the setFieldsOnGraphQLNodeType function.
* Add query test
Adds a test that uses graphql to query a node with its excerpt
* Regroup tests
Regroups tests so that graphql queries and node tests are in their own
groups
* Fix linting errors
Fixes linting errors that were causing issues on travisCI
* Format
`gatsby-transformer-remark` allows you to get an excerpt from a markdown post. By default, it will prune the first 140 characters, but you can optionally specify a `pruneLength` in the graphql query.
12
+
13
+
```graphql
14
+
{
15
+
allMarkdownRemark {
16
+
edges {
17
+
node {
18
+
excerpt(pruneLength: 280)
19
+
}
20
+
}
21
+
}
22
+
}
23
+
```
24
+
25
+
You can also manually mark in your markdown where to stop excerpting—similar to Jekyl. `gatsby-transformer-remark` uses [gray-matter]() to parse markdown frontmatter, so you can specify an excerpt_separator, as well as any of the other options mentioned [here](), in the `gatsby-config.js` file.
26
+
27
+
```json
28
+
{
29
+
resolve: `gatsby-transformer-remark`,
30
+
options: {
31
+
excerpt_separator: `<!-- end -->`
32
+
}
33
+
}
34
+
```
35
+
36
+
Any file that does not have the given excerpt_separator will fall back to the default pruning method.
You can manually mark in your markdown where to stop excerpting—similar to Jekyl. `gatsby-transformer-remark` uses [gray-matter]() to parse markdown frontmatter, so you can specify an excerpt_separator, as well as any of the other options mentioned [here](), in the `gatsby-config.js` file.
11
+
12
+
<!-- end -->
13
+
14
+
```json
15
+
{
16
+
resolve: `gatsby-transformer-remark`,
17
+
options: {
18
+
excerpt_separator: `<!-- end -->`
19
+
}
20
+
}
21
+
```
22
+
23
+
Any file that does not have the given excerpt_separator will fall back to the default pruning method.
`gatsby-transformer-remark` allows you to get an excerpt from a markdown post. By default, it will prune the first 140 characters, but you can optionally specify a `pruneLength` in the graphql query.
0 commit comments