Pass the filename as an argument to Document#slug

This commit is contained in:
Chris Frederick 2014-09-01 12:45:41 +09:00
parent 18eb8e6fb7
commit bcb6798838
1 changed files with 7 additions and 5 deletions

View File

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