Skip to content

sillylogger/jekyll-directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jekyll::DirectoryTag

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.

Installation

In your plugins directory:

curl -L -O https://github.com/sillylogger/jekyll-directory/raw/master/_plugins/directory_tag.rb

Syntax

{% directory path: path/from/source [reverse] [exclude] %}
  {{ file.date }}
  {{ file.name }}
  {{ file.slug }}
  {{ file.url }}

  {{ forloop }}
{% enddirectory %}

parameters:

  • reverse - Defaults to 'false', ordering files the same way ls does: 0-9A-Za-z.
  • exclude - Defaults to '.html$', a Regexp of files to skip.

file attributes:

  • url - The absolute path to the published file
  • name - The basename
  • date - The date extracted from the filename, otherwise the file's creation time
  • slug - The basename with date and extension removed

forloop attributes:

See Shopify's liquid documentation here.

Usage

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 %}

About

a jekyll plugin for exposing a directory's files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •