This tag lets you iterate over files at a particular path. The directory tag yields a file
object and a forloop
object.
If files conform to the standard Jekyll format, YYYY-MM-DD-file-title, then those attributes will be populated on that file
object.
In your plugins directory:
curl -L -O https://github.com/sillylogger/jekyll-directory/raw/master/_plugins/directory_tag.rb
{% directory path: path/from/source [reverse] [exclude] %}
{{ file.date }}
{{ file.name }}
{{ file.slug }}
{{ file.url }}
{{ forloop }}
{% enddirectory %}
reverse
- Defaults to 'false', ordering files the same wayls
does: 0-9A-Za-z.exclude
- Defaults to '.html$', a Regexp of files to skip.
url
- The absolute path to the published filename
- The basenamedate
- The date extracted from the filename, otherwise the file's creation timeslug
- The basename with date and extension removed
See Shopify's liquid documentation here.
images:
<ul>
{% directory path: images/vacation exclude: private %}
<li>
<img src="{{ file.url }}"
alt="{{ file.name }}"
datetime="{{ file.date | date_to_xmlschema }}" />
</li>
{% enddirectory %}
</ul>
downloads:
{% directory path: torrents/complete %}
<a href="{{ file.url }}" >{{ file.name }}</a>{% unless forloop.last %}, {% endunless %}
{% enddirectory %}