Eleventy: Equivalent for site.static_file in a loop

Created on 17 Sep 2018  路  6Comments  路  Source: 11ty/eleventy

Playing around with Eleventy and stumbled about finding a equivalent for this Jekyll/Liquid loop
{% for image in site.static_files %} <img src=""{{ image.url }}> {% endfor %}
any quick hint where to look?

education

Most helpful comment

That said, pass-through files serve a similar if not the same purpose. We could make pass-through files available as an implicit collection.

All 6 comments

What do you expect site.static_files to contain?

You can use Data files or even JavaScript data files to provide your templates with additional data.

Group of images that are not part of a specific Blog post. But i will make sure to read through your links :)

This looks like what @mittelgrau is referencing: https://jekyllrb.com/docs/static-files/

I don鈥檛 believe that we鈥檒l ever have this idea of static versus dynamic files because we decide what to process based on file extension, not on whether or not the file has front matter.

@kleinfreund is right that you can build an array of files using https://www.11ty.io/docs/data-js/ JavaScript Data Files to iterate over files in a directory.

Eventually we might be able to do this with #117 and data files to assign Tags to these new file types. But that鈥檚 later on.

Please reopen if you have more questions!

That said, pass-through files serve a similar if not the same purpose. We could make pass-through files available as an implicit collection.

We could make pass-through files available as an implicit collection.

Oh now there鈥檚 a very interesting idea indeed.

Opened as #237

Was this page helpful?
0 / 5 - 0 ratings