jnordberg/wintersmith

Content-Tree in page.parent is incomplete (missing other content groups)

MaZderMind opened this issue · 3 comments

In a Template and using util.inspect to inspect part of the Content-Tree. I'd like to access parts of the Content-Tree relative to the current Page. I found page.parent to be particularly useful, but when I installed wintersmith-image-generator which contains a generator I found that accessing page.parent would not give me the ContentTree-Items generated by it.

Considering this Template

pre(style='color: green')
  = util.inspect(contents.pictures, {depth: 0})
pre(style='color: red')
  = util.inspect(page.parent.pictures, {depth: 0})

hr

pre(style='color: green')
  = util.inspect(contents.pictures._, {depth: 1})
pre(style='color: red')
  = util.inspect(page.parent.pictures._, {depth: 1})

would, for example, give me this output (green = accessed via the content variable, red = accessed via page.parents):
screenshot from 2015-11-25 14 38 19

I expected to be both ways to access the conten-tree to be equal. Is there a way to access the complete Content-Tree relative to the current page?

This is a bug, they should be equal.

Try adding item.parent = root after this line and see if it fixes it
https://github.com/jnordberg/wintersmith/blob/master/src/core/content.coffee#L279

Yep, that fixes it. Should i send in a PR?

Yes that would be great, thanks!