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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-plugin-ghost-images

v2.0.2

Published

Gatsby plugin that downloads images from Ghost CMS to be used with Gatsby image tools.

Downloads

153

Readme

gatsby-plugin-ghost-images

Released under MIT license. gatsby-plugin-ghost-images npm package version. PRs welcome!

Downloads images from Ghost CMS so they can be processed with the Gatsby image tool chain. This plugin is designed to seamlessly work with a headless Ghost CMS, but it should also work with other content management systems.

Install

yarn add gatsby-plugin-ghost-images

Note that gatsby-source-filesystem is installed as a dependency of this plugin, because it provides needed functions. It is not required to include gatsby-source-filesystem in your gatsby-config.js as all images are fetched remotely from the CMS.

Works best with...

While you can use gatsby-plugin-ghost-images on its own, you most likely want to use it with Gatsby image and sharp plugins:

yarn add gatsby-plugin-sharp gatsby-transformer-sharp gatsby-image

GraphQL schema

Note that the GraphQL schema must be explicitely typed. If you use this plugin in conjunction with gatsby-source-try-ghost this is automatically done for you.

How to use

// In your gatsby-config.js
plugins: [
    // sharp plugins are only needed if you want to use gatsby image processing tools
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
    {
        resolve: `gatsby-plugin-ghost-images`,
        options: {
            // An array of node types and image fields per node
            // Image fields must contain a valid absolute path to the image to be downloaded
            lookup: [
                {
                    type: `GhostPost`,
                    imgTags: [`feature_image`],
                },
                {
                    type: `GhostPage`,
                    imgTags: [`feature_image`],
                },
                {
                    type: `GhostSettings`,
                    imgTags: [`cover_image`],
                },
            ],
            // Additional condition to exclude nodes 
            // Takes precedence over lookup
            exclude: node => (
                node.ghostId === undefined
            ),
            // Additional information messages useful for debugging
            verbose: true,
            // Option to disable the module (default: false)
            disable: false,
        },
    },
]

Image nodes

For each image, this plugin creates a new file node and puts the image data into the cache. For convenience all images are also attached to the original node. We adopt a naming convention, so the reference names are automatically generated. First the image tag name is extended with _sharp, next it is transformed into camel Case. For example:

feature_image -> feature_image_sharp -> featureImageSharp

With this naming convention there is no need to provide a target name.

Details

This plugin will dramatically improve user experience and site performance! Gatsby provides amazing image processing tools that natively ships with lazy loading, adaptive image resolutions and much more. Get all these image features into your Ghost site with this plugin.

How to query

{
  allGhostPost {
    edges {
      node {
        featureImageSharp {
          id
        }
      }
    }
  }
}

How to query images created by sharp

{
  allGhostPost {
    edges {
      node {
        featureImageSharp {
          childImageSharp {
            fluid(maxWidth: 1920) {
              ...GatsbyImageSharpFluid_withWebp
            }
          }
        }
      }
    }
  }
}

How to access in React code

import Img from "gatsby-image"

...

const fluidImg = ghostPost.featureImageSharp.childImageSharp.fluid

<Img fluid={fluidImg} />

Contributions

PRs are welcome! Consider contributing to this project if you are missing feature that is also useful for others. Explore this guide, to get some more ideas.

Copyright & License

Copyright (c) 2020 styxlab - Released under the MIT license.