Add Document#slug

This commit is contained in:
Chris Frederick 2014-08-26 11:46:01 +09:00
parent cc4a0d1704
commit a72706ace6
1 changed files with 10 additions and 1 deletions

View File

@ -45,6 +45,15 @@ module Jekyll
File.basename(path, suffix)
end
# The sluggified base filename of the document.
#
# Returns the base filename of the document in lowercase, with every
# sequence of spaces and non-alphanumeric characters replaced with a
# hyphen.
def slug
File.basename(path, ".*").downcase.gsub(/[\W\s]+/, '-')
end
# The extension name of the document.
#
# Returns the extension name of the document.
@ -129,7 +138,7 @@ module Jekyll
collection: collection.label,
path: cleaned_relative_path,
output_ext: Jekyll::Renderer.new(site, self).output_ext,
name: basename(".*")
name: slug
}
end