# File lib/jekyll/tags/post_url.rb, line 8 def initialize(name) @name = name all, @path, @date, @slug = *name.sub(%r^/!, "").match(MATCHER) unless all raise Jekyll::Errors::InvalidPostNameError, "'#{name}' does not contain valid date and/or title." end @name_regex = %r^#{path}#{date}-#{slug}\.[^.]+! end
# File lib/jekyll/tags/post_url.rb, line 25 def ==(other) other.basename.match(@name_regex) end
# File lib/jekyll/tags/post_url.rb, line 29 def deprecated_equality(other) slug == post_slug(other) && post_date.year == other.date.year && post_date.month == other.date.month && post_date.day == other.date.day end
# File lib/jekyll/tags/post_url.rb, line 20 def post_date @post_date ||= Utils.parse_date(date, "\"#{date}\" does not contain valid date and/or title.") end
Construct the directory-aware post slug for a Jekyll::Post
other - the Jekyll::Post
Returns the post slug with the subdirectory (relative to _posts)
# File lib/jekyll/tags/post_url.rb, line 42 def post_slug(other) path = other.basename.split("/")[0...-1].join("/") if path.nil? || path == "" other.data["slug"] else path + "/" + other.data["slug"] end end