npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gatsby-wordpress-gutenberg

v0.0.5

Published

Gutenberg Blocks plugin for gatsby-plugin-wordpress

Readme

gatsby-wordpress-gutenberg

Gutenberg Blocks plugin for gatsby-plugin-wordpress

This is an experimental plugin (I.e. not production-ready 😏) that takes blocks from Gutenberg, and transforms them to an array of blocks that tell you the block type, and the inside content (in most cases without the html).

Installation

This plugin works in conjunction with gatsby-plugin-wordpress, so you will need to add and configure that first. You will then need to add the below code to your Wordpress themes functions.php:

add_action(
	'rest_api_init',
	function () {
		if ( ! function_exists( 'use_block_editor_for_post_type' ) ) {
			require ABSPATH . 'wp-admin/includes/post.php';
		}

		// Surface all Gutenberg blocks in the WordPress REST API
		$post_types = get_post_types_by_support( [ 'editor' ] );
		foreach ( $post_types as $post_type ) {
			if ( use_block_editor_for_post_type( $post_type ) ) {
				register_rest_field(
					$post_type,
					'blocks',
					[
						'get_callback' => function ( array $post ) {
							return parse_blocks( $post['content']['raw'] );
						},
					]
				);
			}
		}
	}
);

Now you can add this plugin.

gatsby-config.js

...
{
  resolve: `gatsby-wordpress-gutenberg`,
  options: {
    baseUrl: <url>, // Your Wordpress URL, without the protocol - required
    https: true, // optional, default: true
    includedTypes: ['wordpress__POST', 'wordpress__PAGE'], // Nodes that contain Gutenberg blocks to transform - optional
    excludedBlocks: [], // Blocks to exclude - optional
  }
},
...

Usage

For each type that you chose to transform, a fields/blocks field will appear, which is a union field - here you can select blocks to query. Your data will then contain an array of objects, containing the fields you selected, in the order created in the post/page etc. You can create components for each type, and use that component within a loop if it matches the current type. For example:

const ParagraphBlock = ({ html }) => (<div className="content" dangerouslySetInnerHTML={html} />)
...
return (
  <Layout>
    {data.wordpressPost.fields.blocks.map(block => (
      <div key={block.id}>
        {block.type === 'Paragraph' && <ParagraphBlock html={block.content.html} />}
        {block.type === 'Image' && <Img fluid={block.content.image.localFile.childImageSharp.fluid} alt={block.content.image.altText} />}
        ...etc
      </div>
    ))
  </Layout>
)
...

Try visiting the Graphiql explorer to see how this works - some examples are below.

Examples

Paragraph

query Posts {
  allWordpressPost {
    nodes {
      fields {
        blocks {
          ... on GutenbergBlockParagraph {
            id
            type
            content {
              html
            }
          }
        }
      }
    }
  }
}

Heading

query Posts {
  allWordpressPost {
    nodes {
      fields {
        blocks {
          ... on GutenbergBlockHeading {
            id
            type
            content {
              text
              size
            }
          }
        }
      }
    }
  }
}

Images

Images are downloaded and processed using gatsby-source-filesystem. Each image field will have a localFile object inside it.

query Posts {
  allWordpressPost {
    nodes {
      fields {
        blocks {
          ... on GutenbergBlockImage {
            id
            type
            content {
              image {
                title
                altText
                caption
                localFile {
                  childImageSharp {
                    fluid {
                      ...GatsbyImageSharpFluid
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

And other media types such as Gallery, Audio, Video, File, and MediaText also have this.