From ff3edbc16b9d11f56d4c45b2737cd6f693cb8505 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 19 Mar 2015 17:36:15 -0700 Subject: [PATCH] static files mtime liquid should return a Time obj --- lib/jekyll/static_file.rb | 14 ++++++---- site/_data/docs.yml | 1 + site/_docs/static_files.md | 52 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 site/_docs/static_files.md diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 0ab88cbd..454f1247 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -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 diff --git a/site/_data/docs.yml b/site/_data/docs.yml index 474f73fa..bcdf352d 100644 --- a/site/_data/docs.yml +++ b/site/_data/docs.yml @@ -13,6 +13,7 @@ - posts - drafts - pages + - static-files - variables - collections - datafiles diff --git a/site/_docs/static_files.md b/site/_docs/static_files.md new file mode 100644 index 00000000..00afbaec --- /dev/null +++ b/site/_docs/static_files.md @@ -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: + +
+ + + + + + + + + + + + + + + + + + + + + +
VariableDescription

file.path

+ + The relative path to the file. + +

file.modified_time

+ + The `Time` the file was last modified. + +

file.extname

+ + The extension name for the file, e.g. + .jpg for image.jpg + +

+