syntra / gatsby-remark-reading-time

Gatsby remark plugin to add an estimated reading time field to all remark nodes
MIT License
25 stars 16 forks source link

Is not a plugin no compiled .js #4

Open donaldboulton opened 5 years ago

donaldboulton commented 5 years ago

warning Plugin gatsby-remark-reading-time is not compatible with your gatsby version 2.2.9 - It requires gatsby@next error This plugin file is using both CommonJS and ES6 module systems together which we don't support. You'll need to edit the file to use just one or the other. It has no js at all This is not even a module or plugin

RubenNijhuis commented 5 years ago

I have the same problem, it would be fine if the creator of the plugin would be making a fix.

donaldboulton commented 5 years ago

He was just working on one of his repos yesterday, I guess he gave up on this, as he only made one push to it, and one update. Some Gatsby plugins do not work, Gatsby is into look at all our plugins working or barely working or not. They do not seem to care and tell you to get ahold of the repo owner and dish it out with them.

vickylance commented 5 years ago

@donaldboulton @RubenNijhuis I have fixed the warning and uploaded as a fork here.

https://github.com/vickylance/gatsby-remark-reading-time-v2

Just in case if anyone from the future is facing this issue

AriTheElk commented 5 years ago

@vickylance you're more than welcome to open a PR. I stepped away from gatsby temporarily while working on some other stuff. I'm pushing new versions to all my major repos

The reason I didn't maintain this much, is because reading time is included inside the remark gatsby plugin now (although I'm unsure if it's officially documented). Making plugins like this one just needless extra overhead.

To use the time to read included in remark, just include timeToRead in your GraphQL query like so:

export const query = graphql`
  {
    allMarkdownRemark() {
      edges {
        node {
          id
          timeToRead
          frontmatter {
            title
            date(formatString: "MMMM Do, YYYY")
            tags
          }
        }
      }
    }
  }
`;
vickylance commented 5 years ago

@garetmckinley Wow that's fantastic didn't know transformer by default had that. Although I had to write a condition on my own to show up min or mins depending upon if the value is 1 or not. But one less plugin always good.

JesseSingleton commented 5 years ago

@garetmckinley Hey! I just stumbled across this thread after wanting to implement reading time from your plugin at https://www.gatsbyjs.org/packages/gatsby-remark-reading-time/.

I wasn't aware it was natively in gatsby-transformer-remark until you mentioned it; it seems a little counter productive to keep this in the gatbsy docs if this plugin is no longer being maintained and the basic functionality is now in the primary plugin.

To avoid confusion in the future would you mind if I went ahead and removed this plugin from the gatsby docs? Unless you had a better suggestion!

AriTheElk commented 5 years ago

@JesseSingleton tbh I think first we need to add proper documentation to the official remark transformer. Without looking through the code, there's no way to know that the reading time property is available for use.

Once the documentation is added, the readme in the repo can serve as a redirect back to the official remark plugin.

JesseSingleton commented 5 years ago

@garetmckinley Yes that probably sounds like a better plan. You mentioned above that it was added recently but I had a look through the git blame and it that snippet has been in there for about 3 years. Link here.

The other fields such as heading and excerpt are on the official readme, so looks to me like all it needs is a section under the How to Query section of the docs. I can probably do that.