These are chat archives for jescalan/roots

8th
Jun 2017
bdekok
@bdekok
Jun 08 2017 09:34

Hello i'm having some problems with a roots-contentful upgrade from 0.0.7 to 0.0.9, for some reason the contentful entry seems fine the first few times, but it seems to loop one time too many with entry resolved to null

In my template i've output entry for debugging, this is the result:

compiling... {"sys":{"id":"6fdvOTIB9uuWosMyEAOQgq","revision":1,"type":"Entry","locale":"en-GB","space":{"sys":{"id":"xlpd2rg2beuq","type":"Link"}},"contentType":{"sys":{"id":"article","type":"Link"}},"createdAt":"2017-06-08T08:44:28.649Z","updatedAt":"2017-06-08T08:44:28.649Z"},"category":"Blog","title":"Test","subtitle":"Test","uri":"test","description":"test","content":"test","_urls":["/article/test.html"],"_url":"/article/test.html"}
null
{ TypeError: /Users/brent/projects/worth.systems/views/article.jade:6
    4|   section.block.block--banner.block--banner--article
    5|     - console.log(JSON.stringify(entry))
  > 6|     if (entry.headerImage)
    7|       img.block__image(itemprop='image', src!= asset(entry.headerImage, {w: 1366, h: 798}),srcset!=asset(entry.headerImage2x,{w:1366,h:798})+" 2x", alt=entry.title, width='1366', height='798')
    8|         
    9| block content

Cannot read property 'headerImage' of null
Looking at the roots-contentful source I suspected it might have to do with our unused second locale for the website, however removing that didn't solve this behaviour
bdekok
@bdekok
Jun 08 2017 09:42
I seem to have solved it by commenting out @roots.config.locals.entry = null; not sure what is exactly going on though
bdekok
@bdekok
Jun 08 2017 09:52
https://github.com/carrot/roots-contentful/blob/master/lib/index.coffee looks to me that line 201 and 202 should be reversed when resolving the promise, but not sure. Pretty strange that other people don't seem to experience this problem
Jeff Escalante
@jescalan
Jun 08 2017 13:56
Interesting, haven't used this for a while, but would you PR that change?