GithubHelp home page GithubHelp logo

spike-contentful's Issues

An in-range update of rimraf is breaking the build 🚨

The devDependency rimraf was updated from 2.6.2 to 2.6.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rimraf is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 6 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Templates not working on fresh Spike install

Spike version: 2.2.1
Node version: 9.11.1 using NVM (have also tried 9.3.0

Demo: https://github.com/craigmdennis/example-spike-contentful

  1. spike new example.com
? What is the name of your project? example
? Describe your project Example
? What is your github username? craigmdennis
? Would you like to use whitespace-sensitive syntax? No
? Would you like a production config file? No
  1. spike compile
  2. npm i spike-contentful -S
  3. Add configuration from the README using the demo Contentful app
const htmlStandards = require('reshape-standard')
const cssStandards = require('spike-css-standards')
const jsStandards = require('spike-js-standards')
const pageId = require('spike-page-id')
const env = process.env.SPIKE_ENV
const Contentful = require('spike-contentful')
const locals = {}

module.exports = {
  plugins: [
    new Contentful({
      addDataTo: locals,
      accessToken: '1e1dd64d5385d015b2e8f622f622b67c4147a812d7ab3f8146e583416009f31b',
      spaceId: 'noiekra805sy',
      contentTypes: [
        {
          name: 'posts',
          id: '2wKn6yEnZewu2SCCkus4as',
          template: {
            path: 'templates/post.html',
            output: post => {
              return `posts/${post.id}.html`
            }
          }
        }
      ]
    })
  ],
  devtool: 'source-map',
  ignore: ['**/layout.html', '**/_*', '**/.*', 'readme.md', 'yarn.lock', 'package-lock.json'],
  reshape: htmlStandards({
    locals: () => locals,
    minify: env === 'production'
  }),
  postcss: cssStandards({
    minify: env === 'production',
    warnForDuplicates: env !== 'production'
  }),
  babel: jsStandards()
}
  1. spike compile

Instead of rendering post pages, Spike outputs a single templates/post.html file, as if it were a normal page.

  1. When trying to use {{ item.title }} required in the README, there is an undefined error for item:
{ ModuleBuildError: Module build failed: TypeError: Cannot read property 'title' of undefined
    at eval (eval at module.exports (/Users/craigmdennis/Sites/example.com/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:156)
    at eval (eval at module.exports (/Users/craigmdennis/Sites/example.com/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:170)
    at evalNode (/Users/craigmdennis/Sites/example.com/node_modules/reshape-eval-code/lib/index.js:27:70)
    at util.modifyNodes (/Users/craigmdennis/Sites/example.com/node_modules/reshape-eval-code/lib/index.js:21:40)
    at when.resolve.then (/Users/craigmdennis/Sites/example.com/node_modules/reshape-plugin-util/lib/index.js:26:29)
    at tryCatchReject (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:592:4)
    at ContinuationTask.run (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:702:24)
    at Scheduler._drain (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/Scheduler.js:62:19)
    at runLoaders (/Users/craigmdennis/Sites/example.com/node_modules/webpack/lib/NormalModule.js:195:19)
    at /Users/craigmdennis/Sites/example.com/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /Users/craigmdennis/Sites/example.com/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/Users/craigmdennis/Sites/example.com/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at tryCatchReject (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/Users/craigmdennis/Sites/example.com/node_modules/when/lib/Scheduler.js:27:9) id: '6647cf5f' }

This is the contents of the post.html template:

<extends src='../layout.html'>
  <block name='content'>
    <h1>{{ item.title }}</h1>
  </block>
</extends>

JSON.stringify(post) also causes a Module build failed: TypeError: Converting circular structure to JSON with the default Contentful 'Blog' app. When simply referencing parts of the JSON it works fine:

<ul>
  <each loop="post of contentful.posts">
    <li>{{ post.fields.title }}</li>
  </each>
</ul>

so getting data from Contentful is not the issue.

Let me know if I'm doing something obviously wrong. If so, I can submit a PR to update the README to clarify. Otherwise, suggestions?

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

ContentType template not running

Hi there!

Just playing with Spike and I like the cleanliness so far. I'm trying to get a basic blog setup through contentful and I'm trying the template option configured like so:

new Contentful({
      addDataTo: locals,
      accessToken: 'xxxxx',
      spaceId: 'xxxxx',
      contentTypes: [
        {
          name: 'podcasts',
          id: 'podcast',
          filters: {
            order: 'fields.number'
          },
          template: {
            path: 'views/_podcast.html',
            output: (podcast) => `podcasts/${podcast.number}-${slug(podcast.guestName)}.html`
          }
        },
        {
          name: 'notes',
          id: 'notes'
        }
      ]
    })

I have a basic template using item as a variable in views/_podcast.html (same directory as my index) but the output function never runs.

I dig a little bit of digging and it keeps hitting https://github.com/static-dev/spike-contentful/blob/master/lib/index.js#L53 instead of going ahead.

templatePairs is correct (= { 'views/_podcast.html': 0 }) but p is pointing to the index.html (my only template) so it never runs the past L53. If I don't ignore my _podcast.html template it causes an error because item, if I ignore it ctx.resourcePath never points to the _podcast.html template and therefore never goes further.

Am I doing something wrong or is this broken?

Better error message when template path is wrong

Right now, if you have the wrong path to a single page template, the error will be that item doesn't exist, since the template will try to be compiled normally. The plugin should throw when it can't resolve a template path instead ✨

Name should be default if the id is not included

Contentful used to have long confusing IDs, which made adding a name param necessary for sanity. However, they now use camelCase slugified field names as their IDs, so I am finding myself passing an exact repetition as the name and ID. For example:

contentTypes: [
  { name: 'blogPosts', id: 'blogPosts' }
  { name: 'authors', id: 'authors' }
]

This would represent contentful's default. So I'd say if no id is provided, it should be set equal to name 😁

Count of Contenful results

Is there a way to get a total count of the entries that my page receives from contentful, and paste it into the HTML?

An in-range update of contentful is breaking the build 🚨

The dependency contentful was updated from 7.0.5 to 7.0.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

contentful is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v7.0.6

7.0.6 (2019-01-07)

Bug Fixes

  • sdk-core: Bump sdk version (27e22f0)
Commits

The new version differs by 2 commits.

  • 27e22f0 fix(sdk-core): Bump sdk version
  • 4d543db fix(docs) Add proper (absolute) links to README.md file (#286)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Default transform function cant handle circular dependencies

So the contentful client resolves links and references is using proxies. So if you have a circular dependency of any length (ex. post1 references post2 references post3 references post1), the transform function, which is recursive and causes getters to resolve by walking properties directly, will end in an infinite loop.

This is something of an edge case, but it has been reported twice already, and in addition to all the other drawbacks associated with the transform function leads me to believe that it should not be true by default, and instead should be false by default, or even extracted to a separate library entirely.

Allow multiple content types to use same layout

This is probably the most edge case of edge cases, but I was trying to automatically generate multiple pages from a single content type and ran into a problem. The set up is this:

  • I set up two content types, 'resource' and 'landing page' that have the same content model but are separate in Contentful and use separate templates.
  • I needed to add thank you pages to redirect people to, so I created a thank you page layout and made a second call to 'resource' with a different name and the thank you layout. I also made a second call to 'landing page' and used the same thank you template.
  • Doing so caused only the landing page thank you pages to output, but all the data was present in the output JSON file.

I took a wild guess and just copied the templates so each content type used its own layout and that fixed it.

Not sure if this is something that needs changed or documented, but I wanted to put this out there for thoughts.

Write test for `includeLevel`

Because we should have tests for every param!

Edit: Also should have docs for this in the readme. Doesn't look like there's a central spot where all the options are documented.

/cc @elvingm

Throws an error when setting the limit past 100

Trying to add this content type in the settings:

new Contentful({
  addDataTo: locals,
  accessToken: 'xxx',
  spaceId: 'xxx',
  contentTypes: [{
    name: 'blogs',
    id: 'blogPost'
    filters: {
      order: '-fields.date',
      limit: 1000
    }
  }]
})

Throws this error:

Error: ValidationError: [spike-contentful constructor] option "contentTypes" at position 1 fails because [spike-contentful constructor] option [spike-contentful constructor] option "limit" must be less than or equal to 100

Since the Contentful API allows for up to 1000 entries (link), is there a reason this plugin limits it to 100?

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.