Giter VIP home page Giter VIP logo

gatsby-remark-text-composition's Introduction

gatsby-remark-text-composition

Adds text composition fields to all remark nodes in your Gatsby project. Supports both MD and MDX!

Installation

Install the plugin with npm or yarn.

# npm
npm install gatsby-remark-text-composition

# yarn
yarn add gatsby-remark-text-composition

Markdown (MD)

To use the plugin with regular markdown files, add it to the gatsby-transformer-remark plugins array in gatsby-config.js.

// gatsby-config.js
  ...
  plugins: [
    ...
    {
      resolve: "gatsby-transformer-remark",
      options: {
        plugins: [
          "gatsby-remark-text-composition",
          // ...
        ],
      },
    },
  ]

MDX

To use the plugin with MDX, add it as a regular plugin in gatsby-config.js.

// gatsby-config.js
  ...
  plugins: [
    ...
    'gatsby-remark-text-composition',
  ],

Usage

The gatsby-remark-text-composition data is queried in different ways depending on if you're using markdown or MDX.

Markdown (MD)

If you are transforming markdown with gatsby-transformer-remark, you can query the text composition data like this:

const result = await graphql(`
	query {
		allMarkdownRemark {
			nodes {
				fields {
					readingTime {
						milliseconds
						minutes
						words
					}
				}
			}
		}
	}
`)

MDX

If you are using MDX with gatsby-plugin-mdx, you can query the text composition data like this:

export const query = graphql`
	query {
		allMdx {
			nodes {
				fields {
					readingTime {
						milliseconds
						minutes
						words
					}
				}
			}
		}
	}
`

Data

The fields available in gatsby-remark-text-composition are explained below.

Reading time

  • minutes: Estimated reading time in minutes (number).
  • milliseconds: Estimated reading time in milliseconds (number).
  • words: Calculated amount of words, which is used when estimating reading time (number).

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.