Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-source-ghost

Package Overview
Dependencies
Maintainers
11
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-ghost

Gatsby source plugin for building websites using the Ghost API as a data source.

  • 3.1.1
  • npm
  • Socket score

Version published
Weekly downloads
313
decreased by-74.94%
Maintainers
11
Weekly downloads
 
Created
Source

Gatsby Source Ghost

Source plugin for pulling data into Gatsby.js from the Ghost Public API.

Install

npm install --save gatsby-source-ghost

How to use

You need to specify three properties in your gatsby-config.js:

{
   resolve: `gatsby-source-ghost`,
   options: {
       apiUrl: `https://<your-subdomain>.ghost.io`,
       contentApiKey: `<your content api key>`
   }
}

apiUrl The admin or API URL for your Ghost site. For Ghost(Pro) customers this is your .ghost.io domain. For self hosters it is your main domain unless you have a separate admin url configured. Note that this URL should be served over HTTPS.

contentApiKey The "Content API Key" copied from the "Integrations" screen in Ghost Admin.

How to query

There are 4 node types available from Ghost: Post, Page, Author and Tag.

Documentation for the full set of fields made available for each resource type can be found in the Public API docs.

Posts and Pages have the same properties.

You can query Post nodes created from Ghost like the following:

{
  allGhostPost(sort: { order: DESC, fields: [published_at] }) {
    edges {
      node {
        id
        slug
        title
        html
        published_at
        ...
        tags {
          id
          slug
          ...
        }
        primary_tag {
          id
          slug
          ...
        }
        authors {
          id
          slug
          ...
        }
      }
    }
  }
}

A common but tricky example of filtering posts by tag, can be achieved like this (Gatsby v2+):

{
  allGhostPost(filter: {tags: {elemMatch: {slug: {eq: $slug}}}}) {
    edges {
      node {
        slug
        ...
      }
    }
  }
}

You can query Page nodes created from Ghost like the following:

{
  allGhostPage {
    edges {
      node {
        id
        slug
        title
        html
        ...
      }
    }
  }
}

You can query Tag nodes created from Ghost like the following:

{
  allGhostTag {
    edges {
      node {
        id
        slug
        name
        ...
      }
    }
  }
}

You can query Author nodes created from Ghost like the following:

{
  allGhostAuthor {
    edges {
      node {
        id
        slug
        name
        ...
      }
    }
  }
}

Copyright (c) 2018-2019 Ghost Foundation - Released under the MIT license.

Keywords

FAQs

Package last updated on 09 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc