Skip to content

Commit

Permalink
Move Date object from page.title to page.date
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredxing committed Oct 9, 2014
1 parent aad5d0b commit 122f33b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/jekyll-archives/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Archive
posts
type
title
date
name
path
url
Expand Down Expand Up @@ -116,14 +117,21 @@ def to_liquid(attrs = nil)

# Produce a title object suitable for Liquid based on type of archive.
#
# Returns the title as a Date (for date-based archives) or a
# String (for tag and category archives)
# Returns a String (for tag and category archives) and nil for
# date-based archives.
def title
if @title.is_a? String
@title
end
end

# Produce a date object if a date-based archive
#
# Returns a Date.
def date
if @title.is_a? Hash
args = @title.values.map { |s| s.to_i }
Date.new(*args)
else
@title
end
end

Expand Down

0 comments on commit 122f33b

Please sign in to comment.