Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-transformer-remark use gray-matter excerpt #2794

Closed
reccanti opened this issue Nov 4, 2017 · 9 comments
Closed

gatsby-transformer-remark use gray-matter excerpt #2794

reccanti opened this issue Nov 4, 2017 · 9 comments

Comments

@reccanti
Copy link
Contributor

reccanti commented Nov 4, 2017

I’m trying to grab excerpts from my markdown files up to a specified separator, similar to how they’re handled by graymatter and jekyll link. Seeing as how this plugin uses graymatter under-the-hood, is there any way to access this functionality?

gatsby-transformer-remark version - 1.7.19
gatsby version - 1.9.73

@KyleAMathews
Copy link
Contributor

This is the relevant code

@reccanti
Copy link
Contributor Author

reccanti commented Nov 7, 2017

Okay! It looks like graymatter accepts an object as a second parameter after content where you can specify whether to get an excerpt and what the excerpt should be. Any idea what the best way to add this functionality would be? Would it be better as a custom plugin, or would it be useful to add this functionality to the main remark plugin?

Sorry if I'm asking a lot. I'm new to working with Gatsby

@reccanti
Copy link
Contributor Author

reccanti commented Nov 7, 2017

Just noticed this. gatsby-transformer-remark relies version 2.1 of graymatter, but the excerpt options were added in version 3.0. I tried updating it in the plugin and tests seem to pass after updating the snapshot

@KyleAMathews
Copy link
Contributor

Oh sweet! Would you like to put together a PR that upgrades gray-matter and documents how to add excerpt support?

You'd also need to modify the existing excerpt functionality to check if there's an excerpt already set and use that instead of generating a new one

resolve(markdownNode, { pruneLength }) {

@reccanti
Copy link
Contributor Author

reccanti commented Nov 7, 2017

Sure, I can take a look at that!

@fxfactorial
Copy link
Contributor

Bump, any way to change the excerpt pruneLength from the 140 default?

@reccanti
Copy link
Contributor Author

reccanti commented Apr 6, 2018

We should close this since it was taken care of in this PR #2883.

@fxfactorial You can updated the pruneLength in your graphql https://using-remark.gatsbyjs.org/excerpts/

@fxfactorial
Copy link
Contributor

fxfactorial commented Apr 6, 2018 via email

@pieh
Copy link
Contributor

pieh commented Apr 6, 2018

Closing this issue, as this was already resolved as mentioned by @reccanti

@pieh pieh closed this as completed Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants