gridsome-source-cosmicjs

1.0.6 • Public • Published

Gridsome Source for Cosmic JS

Source plugin for fetching data into Gridsome from Cosmic JS. Cosmic JS offers a Headless CMS for your Gridsome website.

Install

npm install --save gridsome-source-cosmicjs

How to use

// In your gridsome.config.js
plugins: [
  {
    use: 'gridsome-source-cosmicjs',
    options: {
      bucketSlug: 'gridsome-blog-cosmicjs',
      objectTypes: [`posts`],
      // If you have enabled read_key to fetch data (optional).
      apiAccess: {
        read_key: ''
      }
    },
  }
]

How to query and filter

You can query the nodes created from Cosmic JS with the following:

query IndexQuery {
  posts: allCosmicjsPosts {
    edges {
      node {
        id
        slug
        title
        createdAt(format: "DD MMMM, YYYY")
      }
    }
  }
}

and you can filter specific node using this:

query postQuery($path: String!) {
  post: cosmicjsPosts(path: $path) {
    id
    content
    title
  }
}

Package Sidebar

Install

npm i gridsome-source-cosmicjs

Homepage

cosmicjs.com

Weekly Downloads

12

Version

1.0.6

License

MIT

Unpacked Size

6.14 kB

Total Files

6

Last publish

Collaborators

  • tonyspiro
  • jazibsawar