# gatsby-remark-reading-time

> Adds an estimated reading time field to all remark nodes

Latest version **1.1.0** (published 2019-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-remark-reading-time
pnpm add gatsby-remark-reading-time
yarn add gatsby-remark-reading-time
bun add gatsby-remark-reading-time
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-11-28 |
| First published | 2018-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Garet McKinley |
| Maintainers | garetmckinley |
| Keywords | gatsby, gatsby-plugin, remark, reading time, node, medium, estimate |

## Links

- npm: https://www.npmjs.com/package/gatsby-remark-reading-time
- npm.io page: https://npm.io/package/gatsby-remark-reading-time

## Dependencies (1)

- [reading-time](https://npm.io/package/reading-time.md) ^1.1.3

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-11-28
- 1.0.1 — 2018-09-14
- 1.0.0 — 2018-09-14

## README

# gatsby-remark-reading-time

Adds a medium-like reading time estimate to your Gatsby remark posts. Powered by [`reading-time`](https://github.com/ngryman/reading-time).

This plugin supports both **MD** and **MDX** formats.

## Installation

Install

```bash
yarn add gatsby-remark-reading-time
```

### Markdown (MD)

Add to `gatsby-transformer-remark` plugins in `gatsby-config.js`

```js
// gatsby-config.js
  ...
  plugins: [
    ...
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          `gatsby-remark-reading-time`,
          // ...
        ],
      },
    },
  ]
```

### MDX

Add this plugin outside your `gatsby-plugin-mdx` config, i.e. this plugin should not live within either of `remarkPlugins` or `gatsbyRemarkPlugins` config options:

```js
// gatsby-config.js
  ...
  plugins: [
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        gatsbyRemarkPlugins: [...],
        remarkPlugins: [...],
      },
    },
    'gatsby-remark-reading-time',
     ...
  ],
```

## Usage

The reading time can be queried in the relevant markdown fields. An example of this is shown below for a single post:

### Markdown (MD)

If you are using the `gatsby-transformer-remark` plugin then you can use:

```jsx
export const query = graphql`
  query($slug: String!) {
    markdownRemark(fields: { slug: { eq: $slug } }) {
      htmlAst
      excerpt(pruneLength: 200)
      frontmatter {
        title
        date(formatString: "MMMM Do, YYYY")
      }
      fields {
        slug
        readingTime {
          text
        }
      }
    }
  }
`;
```

### MDX

If you are using the `gatsby-plugin-mdx` plugin then you can use:

```jsx
export const query = graphql`
  query($slug: String!) {
    mdx(fields: { slug: { eq: $slug } }) {
      body
      excerpt(pruneLength: 160)
      frontmatter {
        title
        date(formatString: "MMMM Do, YYYY")
      }
      fields {
        readingTime {
          text
        }
      }
    }
  }
`;
```

### Fields

There are 4 available fields within `readingTime`:

- `text`: '1 min read',
- `minutes`: 1,
- `time`: 60000, (_milliseconds_)
- `words`: 200

## License

MIT

---
_Source: https://npm.io/package/gatsby-remark-reading-time · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
