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: + +
Variable | +Description | +
---|---|
|
+ + + The relative path to the file. + + |
+
|
+ + + The `Time` the file was last modified. + + |
+
|
+
+
+ The extension name for the file, e.g.
+ |
+