{"id":15064997,"url":"https://github.com/cosmicjs/gatsby-source-cosmicjs","last_synced_at":"2025-10-08T19:26:01.028Z","repository":{"id":33010044,"uuid":"134307552","full_name":"cosmicjs/gatsby-source-cosmicjs","owner":"cosmicjs","description":"DEPRECATED Follow the link below to the new source plugin","archived":false,"fork":false,"pushed_at":"2023-03-07T16:20:10.000Z","size":1010,"stargazers_count":8,"open_issues_count":15,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-18T09:51:04.525Z","etag":null,"topics":["api","cms","cosmicjs","gatsby-source","gatsbyjs","headlesscms"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cosmicjs/gatsby-source-cosmic","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cosmicjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-21T18:15:22.000Z","updated_at":"2023-03-07T16:22:00.000Z","dependencies_parsed_at":"2024-09-25T00:29:14.742Z","dependency_job_id":"7488ff79-d739-4325-8a88-da9cd457e670","html_url":"https://github.com/cosmicjs/gatsby-source-cosmicjs","commit_stats":{"total_commits":112,"total_committers":5,"mean_commits":22.4,"dds":0.4375,"last_synced_commit":"545ec6619704d5faee69f6a9fc9dfc619c370dcc"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicjs%2Fgatsby-source-cosmicjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicjs%2Fgatsby-source-cosmicjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicjs%2Fgatsby-source-cosmicjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicjs%2Fgatsby-source-cosmicjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosmicjs","download_url":"https://codeload.github.com/cosmicjs/gatsby-source-cosmicjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248224578,"owners_count":21068073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cms","cosmicjs","gatsby-source","gatsbyjs","headlesscms"],"created_at":"2024-09-25T00:29:11.457Z","updated_at":"2025-10-08T19:25:56.008Z","avatar_url":"https://github.com/cosmicjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IMPORTANT\nThis repo is now deprecated. Please see the new home of the Cosmic Gatsby source plugin at [https://www.npmjs.com/package/@cosmicjs/gatsby-source-cosmic](https://www.npmjs.com/package/@cosmicjs/gatsby-source-cosmic).\n\n# Gatsby Source for Cosmic\n\nSource plugin for fetching data into [Gatsby](https://www.gatsbyjs.org) from [Cosmic](https://cosmicjs.com). Cosmic offers a [Headless CMS](https://cosmicjs.com/headless-cms) for your Gatsby website.\n\n## Install\n\n```\nnpm install --save gatsby-source-cosmicjs\n```\n\n## How to use\n\n[Log into your Cosmic account](https://app.cosmicjs.com/login) to get your `bucketSlug` and `apiAcecss` keys.\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-source-cosmicjs`,\n    options: {\n      bucketSlug: ``, // Get this value in Bucket \u003e Settings\n      objectTypes: [`posts`],\n      // If you have enabled read_key to fetch data (optional).\n      apiAccess: {\n        read_key: ``, // Get this value in Bucket \u003e Settings\n      },\n      localMedia: true, // Download media locally for gatsby image (optional)\n      limit: 1000, // The number of Objects to fetch on each request (optional)\n      debug: false, // Optional: will output details about the API requests to Cosmic\n    }\n  },\n]\n```\n\n### Advanced configuration\n\nFor more control over how content is sourced from Cosmic, you can provide object type overrides\nin the plugin configuration. This can be useful if you are coming up against API limits, or are\ntrying to performance tune your builds. Use at your own risk!\n\n[Get Objects API documentation](https://docs.cosmicjs.com/rest-api/objects.html#get-objects)\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-source-cosmicjs`,\n    options: {\n      bucketSlug: ``, // Get this value in Bucket \u003e Settings\n      objectTypes: [\n        // Basic usage: define objectType as a string\n        `posts`, \n        // Advanced usage: define objectType as an object\n        { \n          type: `news`, // required\n          params: { // any valid API parameter can be used. YMMV!\n            hide_metafields: true, // hides metafields, which can get pretty large. You should only need metadata\n            limit: 100, // this will override the limit only for this object type\n          },\n        },\n      ],\n      // If you have enabled read_key to fetch data (optional).\n      apiAccess: {\n        read_key: ``, // Get this value in Bucket \u003e Settings\n      },\n      localMedia: true, // Download media locally for gatsby image (optional)\n      limit: 1000, // The number of Objects to fetch on each request (optional)\n      debug: false, // Optional: will output details about the API requests to Cosmic\n    }\n  },\n]\n```\n\n### Debugging\n\nUse the `debug: true` flag in your config to get more information about the build. This will provide:\n\n- Exact Cosmic API endpoint being used for each object type\n- Response size returned from Cosmic for the request\n\n## How to query and filter (Not Localized)\n\nYou can query the nodes created from Cosmic with the following:\n\n```graphql\n{\n  allCosmicjsPosts {\n    edges {\n      node {\n        id\n        slug\n        title\n      }\n    }\n  }\n}\n```\n\nand you can filter specific node using this:\n\n```graphql\n{\n  cosmicjsPosts(slug: {eq: ''}) {\n    id\n    slug\n    title\n  }\n}\n```\n\n## How to use Gatsby Image\n\nif `localMedia=true` in plugin config, you can use Gatsby Image.\n\n#### Note: `gatsby-image` and `gatsby-source-filesystem` plugins are required. \n\n```graphql\n{\n  allCosmicjsPosts {\n    edges {\n      node {\n        slug\n        metadata{\n          hero {\n            local {\n              childImageSharp {\n                fluid(quality: 90, maxWidth: 1920) {\n                  ...GatsbyImageSharpFluid_withWebp\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\nRead `gatsby-image` documentation here [here](https://www.gatsbyjs.org/packages/gatsby-image/).\n\n## How to query (Localized)\n\n```graphql\n{\n  allCosmicjsPosts(filter: {locale: {eq: \"en\"}}, sort: {fields: [published_at], order: DESC}) {\n    edges {\n      node {\n        id\n        slug\n        title\n        locale\n      }\n    }\n  }\n}\n```\n\n## Starters\nInstall the [Cosmic Gatsby starter](https://github.com/cosmicjs/gatsby-starter):\n```\nnpm i cosmicjs -g\ncosmic init gatsby-starter\ncd gatsby-starter\ncosmic start\n```\n\nInstall the [Cosmic Gatsby localization starter](https://github.com/cosmicjs/gatsby-localization-starter):\n```\nnpm i cosmicjs -g\ncosmic init gatsby-starter\ncd gatsby-localization-starter\ncosmic start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmicjs%2Fgatsby-source-cosmicjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmicjs%2Fgatsby-source-cosmicjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmicjs%2Fgatsby-source-cosmicjs/lists"}