From bcb6798838b308c1accb137bb9576196947c7a2c Mon Sep 17 00:00:00 2001 From: Chris Frederick Date: Mon, 1 Sep 2014 12:45:41 +0900 Subject: [PATCH] Pass the filename as an argument to Document#slug --- lib/jekyll/document.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index db471c32..2977f152 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -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