GithubHelp home page GithubHelp logo

mpartipilo / gatsby-source-cockpit Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 3.0 30 KB

Gatsby plugin to access remote content from a Cockpit API (http://getcockpit.com/)

License: MIT License

JavaScript 100.00%

gatsby-source-cockpit's Introduction

gatsby-source-cockpit

A Gatsby plugin for accessing remote content from the Cockpit API (http://getcockpit.com/)

Installation:

npm install -save-dev gatsby-source-cockpit

Usage:

Configure the plugin in your gatsby-config.js file.

  {
      resolve: "gatsby-source-cockpit",
      options: {
          host: "http://{YOUR_COCKPIT_URL}",
          accessToken: "{YOUR_ACCOUNT_API_KEY}",
          collectionName: ["Gallery", "Blog", "Pages",...]
      }
  }

Any collections you've created with Cockpit can be accessed from within your project with a simple GraphQL query.

##Example Query

{
    allCockpitPages {
        edges {
            node {
                id
                entry
            }
        }
    }
}

The plugin currently returns both markdown and html, and can be used in tandem with Gatsby's createPages API to programatically serve content created within the Cockpit CMS to your project.

gatsby-source-cockpit's People

Contributors

elizasj avatar mpartipilo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gatsby-source-cockpit's Issues

gatsby build fails

gatsby: 2.0.17
gatsby-plugin-cockpit: 1.0.39

Error Message:

Your plugins must export known APIs from their gatsby-node.js.
The following exports aren't APIs. Perhaps you made a typo or your plugin is outdated?

See https://www.gatsbyjs.org/docs/node-apis/ for the list of Gatsby Node APIs

  • The plugin "[email protected]" is exporting a variable named "collectionsItems" which isn't an API.

  • The plugin "[email protected]" is exporting a variable named "regionsItems" which isn't an API.

  • The plugin "[email protected]" is exporting a variable named "collectionsNames" which isn't an API.

support for WYSIWG

Would be amazing to have support for the WYSIWG fieldtype in Collections. Currently, if used, GraphQL serves out the content and it's HTML tags.

Test title

<p>Test paragraph</p>

Plugin gatsby-source-cockpit returned an error

I've some trouble setting up the source plugin with gatsby. I get this error:

success open and validate gatsby-config — 0.013 s
success load plugins — 0.369 s
success onPreInit — 0.572 s
success delete html and css files from previous builds — 0.068 s
success initialize cache — 0.045 s
success copy gatsby files — 0.034 s
success onPreBootstrap — 0.006 s
info Cockpit host: ########
info Cockpit access token: ########
info Fetching list of assets
error Plugin gatsby-source-cockpit returned an error


  TypeError: Cannot read property 'length' of undefined
  
  - gatsby-node.js:38 Object.exports.sourceNodes
    [renickbuettner2]/[gatsby-source-cockpit]/gatsby-node.js:38:65
  

error Cannot read property 'filter' of undefined


  TypeError: Cannot read property 'filter' of undefined
  
  - api-runner-node.js:274 Promise.mapSeries.catch.then.results
    [renickbuettner2]/[gatsby]/dist/utils/api-runner-node.js:274:42
  
  - util.js:16 tryCatcher
    [renickbuettner2]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [renickbuettner2]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [renickbuettner2]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [renickbuettner2]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:693 Promise._settlePromises
    [renickbuettner2]/[bluebird]/js/release/promise.js:693:18
  
  - async.js:133 Async._drainQueue
    [renickbuettner2]/[bluebird]/js/release/async.js:133:16
  
  - async.js:143 Async._drainQueues
    [renickbuettner2]/[bluebird]/js/release/async.js:143:10
  
  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [renickbuettner2]/[bluebird]/js/release/async.js:17:14
  

error UNHANDLED REJECTION


  TypeError: Cannot read property 'filter' of undefined
  
  - api-runner-node.js:274 Promise.mapSeries.catch.then.results
    [renickbuettner2]/[gatsby]/dist/utils/api-runner-node.js:274:42
  
  - util.js:16 tryCatcher
    [renickbuettner2]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [renickbuettner2]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [renickbuettner2]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [renickbuettner2]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:693 Promise._settlePromises
    [renickbuettner2]/[bluebird]/js/release/promise.js:693:18
  
  - async.js:133 Async._drainQueue
    [renickbuettner2]/[bluebird]/js/release/async.js:133:16
  
  - async.js:143 Async._drainQueues
    [renickbuettner2]/[bluebird]/js/release/async.js:143:10
  
  - async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [renickbuettner2]/[bluebird]/js/release/async.js:17:14
  

Cannot read property 'map' of undefined

Hi there, I’m getting the following error when trying to build a Gatsby (v2.0) site. Noticed this plugin hasn't been updated in a while though, does it support Gatsby v2?

ERROR #11321  PLUGIN

"gatsby-plugin-cockpit" threw an error while running the setFieldsOnGraphQLNodeType lifecycle:

Cannot read property 'map' of undefined

Full error log:

ERROR #11321  PLUGIN

"gatsby-plugin-cockpit" threw an error while running the setFieldsOnGraphQLNodeType lifecycle:

Cannot read property 'map' of undefined



  TypeError: Cannot read property 'map' of undefined
  
  - extend-node-type.js:14 Object.module.exports [as setFieldsOnGraphQLNodeType]
    [niice-insights]/[gatsby-plugin-cockpit]/extend-node-type.js:14:52
  
  - api-runner-node.js:256 runAPI
    [niice-insights]/[gatsby]/dist/utils/api-runner-node.js:256:37
  
  - api-runner-node.js:375 Promise.catch.decorateEvent.pluginName
    [niice-insights]/[gatsby]/dist/utils/api-runner-node.js:375:15
  
  - debuggability.js:384 Promise._execute
    [niice-insights]/[bluebird]/js/release/debuggability.js:384:9
  
  - promise.js:518 Promise._resolveFromExecutor
    [niice-insights]/[bluebird]/js/release/promise.js:518:18
  
  - promise.js:103 new Promise
    [niice-insights]/[bluebird]/js/release/promise.js:103:10
  
  - api-runner-node.js:374 
    [niice-insights]/[gatsby]/dist/utils/api-runner-node.js:374:12
  
  - util.js:16 tryCatcher
    [niice-insights]/[bluebird]/js/release/util.js:16:23
  
  - reduce.js:166 Object.gotValue
    [niice-insights]/[bluebird]/js/release/reduce.js:166:18
  
  - reduce.js:155 Object.gotAccum
    [niice-insights]/[bluebird]/js/release/reduce.js:155:25
  
  - util.js:16 Object.tryCatcher
    [niice-insights]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:547 Promise._settlePromiseFromHandler
    [niice-insights]/[bluebird]/js/release/promise.js:547:31
  
  - promise.js:604 Promise._settlePromise
    [niice-insights]/[bluebird]/js/release/promise.js:604:18
  
  - promise.js:649 Promise._settlePromise0
    [niice-insights]/[bluebird]/js/release/promise.js:649:10
  
  - promise.js:729 Promise._settlePromises
    [niice-insights]/[bluebird]/js/release/promise.js:729:18
  
  - async.js:93 _drainQueueStep
    [niice-insights]/[bluebird]/js/release/async.js:93:12

Plugin gatsby-source-cockpit returned an error

I have 2 types of error first is generated with

host: "http://domain.com/cockpit",

and is

info Fetching list of assets
error Plugin gatsby-source-cockpit returned an error


  TypeError: Cannot read property 'length' of undefined

  - gatsby-node.js:43 Object.exports.sourceNodes
    [gatsby-cockpit]/[gatsby-source-cockpit]/gatsby-node.js:43:53

second one I change the URL and I add a / at the end

host: "http://domain.com/cockpit/",

and it turns into

FetchError: invalid json response body at http://hfp.co.ir/cockpit/auth/login reason: Unexpected token < in JSON at position 0

please guide me.

reporter.list is not a function

When starting the app via gatsby develop, I find the following error. I do have a few collections in the cockpit CMS.

Any guidance?

info Cockpit host: http://localhost:8080
info Cockpit access token: 97265208300e57ea3c008f03922039
info Fetching list of assets
info Assets retrieved: Found 5 assets
info Specified Collections:

 ERROR #11321  PLUGIN

"gatsby-source-cockpit" threw an error while running the sourceNodes lifecycle:

reporter.list is not a function

  45 |
  46 |   reporter.info(`Specified Collections:`);
> 47 |   reporter.list(`collection names`, collectionName);
     |            ^
  48 |
  49 |   const tick = reporter.progress(collectionName.length);
  50 |

File: node_modules/gatsby-source-cockpit/gatsby-node.js:47:12



  TypeError: reporter.list is not a function

Collection Link not working, causes gatsby error

When referencing an item from a different collection, i get this error:

error UNHANDLED REJECTION


  TypeError: Cannot read property 'internal' of null
  
  - infer-graphql-input-fields.js:222 
    [gatsby]/dist/schema/infer-graphql-input-fields.js:222:38

i have a products collection and a contacts collection and each product has multiple contacts associated, the api call directly lists at least the id and title (as shown in cockpit)

{
    entries: [
        {
            title: "product",
            _mby: "5a79af33952bedoc680234702",
            _by: "5a79af33952bedoc680234702",
            _modified: 1529919171,
            _created: 1529671390,
            _id: "5b2ceedeae80fdoc1943926982",
            slug: "product",
            contacts: [
                {
                    _id: "5b2cef7aa48bbdoc2013865485",
                    link: "contacts",
                    display: "max mustermann"
                }
            ]
        }
    ]
}

and the matching contacts entry

{
    entries: [
        {
            name: "max mustermann",
            email: "[email protected]",
            phone: "",
            _mby: "5a79af33952bedoc680234702",
            _by: "5a79af33952bedoc680234702",
            _modified: 1529918980,
            _created: 1529671546,
            _id: "5b2cef7aa48bbdoc2013865485",
            picture: {
                path: "storage/uploads/2018/06/22/5b2cf00f5f72ame.jpg"
            }
        }
    ],
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.