static files mtime liquid should return a Time obj

This commit is contained in:
Parker Moore 2015-03-19 17:36:15 -07:00
parent 68907ab833
commit ff3edbc16b
3 changed files with 62 additions and 5 deletions

View File

@ -18,7 +18,7 @@ module Jekyll
@name = name
@collection = collection
@relative_path = File.join(*[@dir, @name].compact)
@extname = File.extname(@relative_path)
@extname = File.extname(@name)
end
# Returns source file path.
@ -43,9 +43,13 @@ module Jekyll
end
end
def modified_time
@modified_time ||= File.stat(path).mtime
end
# Returns last modification time for this file.
def mtime
File.stat(path).mtime.to_i
modified_time.to_i
end
# Is source path modified?
@ -91,9 +95,9 @@ module Jekyll
def to_liquid
{
"path" => File.join("", relative_path),
"modified_time" => mtime.to_s,
"extname" => extname
"extname" => extname,
"modified_time" => modified_time,
"path" => File.join("", relative_path)
}
end
end

View File

@ -13,6 +13,7 @@
- posts
- drafts
- pages
- static-files
- variables
- collections
- datafiles

View File

@ -0,0 +1,52 @@
---
layout: docs
title: Static Files
permalink: /docs/static-files/
---
In addition to renderable and convertible content, we also have **static
files**.
A static file is a file that does not contain any YAML front matter. These
include images, PDFs, and other un-rendered content.
They're accessible in Liquid via `site.static_files` and contain the
following metadata:
<div class="mobile-side-scroller">
<table>
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><p><code>file.path</code></p></td>
<td><p>
The relative path to the file.
</p></td>
</tr>
<tr>
<td><p><code>file.modified_time</code></p></td>
<td><p>
The `Time` the file was last modified.
</p></td>
</tr>
<tr>
<td><p><code>file.extname</code></p></td>
<td><p>
The extension name for the file, e.g.
<code>.jpg</code> for <code>image.jpg</code>
</p></td>
</tr>
</tbody>
</table>
</div>