Browse source code for this package on GitHub

gatsby-source-hacker-news

Source plugin for pulling data into Gatsby from the Hacker News API

Install

npm install --save gatsby-source-hacker-news

How to use

// In your gatsby-config.js
plugins: [`gatsby-source-hacker-news`];

How to query

You can query nodes created from Hacker News like the following:

query StoriesQuery {
  allHnStory(sort: { fields: [order] }) {
    edges {
      node {
        id
        title
        score
        order
        domain
        url
        by
        descendants
        timeISO(fromNow: true)
        children {
          id
          text
          timeISO(fromNow: true)
          by
        }
      }
    }
  }
}

Was this helpful? edit this page on GitHub