nhoizey’s avatarnhoizey’s Twitter Archive—№ 107,115

  1. Browsing @eleven_ty docs to see data available in a page and in a collection item. title vs item.data.title… Wish it was the same, for simpler Nunjucks macros with a single item object with the same attributes. nho.io/n/2020/10/17/1/
    1. …in reply to @nhoizey
      @eleven_ty Let's say a Nunjucks macro renders the item's date and tags. In a collection loop, if I pass item to the macro, it gets item.date and item.data.tags. In a page template, if I pass page to the same macro, it gets only a few attributes… 😭
      1. …in reply to @nhoizey
        @eleven_ty I’m wondering, is that a limitation of Eleventy, a limitation of Nunjucks, or am I doing it wrong? If you have a simple solution for Nunjucks template fragments or macros, with Eleventy, please share.
        1. …in reply to @nhoizey
          @eleven_ty I currently have in my page layouts to build a "fake" item object similar to the one in loops, to use in the macro: github.com/nhoizey/nicolas-hoizey.com/blob/32ba358472e793b1df0df1ef3ffdf50c3d46645e/src/_layouts/article.njk#L45-L56