Merge pull request #2997 from jekyll/utils-slugify
This commit is contained in:
commit
7fd9f102c0
|
@ -111,11 +111,13 @@ module Jekyll
|
||||||
# hyphen.
|
# hyphen.
|
||||||
def slugify(string)
|
def slugify(string)
|
||||||
unless string.nil?
|
unless string.nil?
|
||||||
|
string \
|
||||||
# Replace each non-alphanumeric character sequence with a hyphen
|
# Replace each non-alphanumeric character sequence with a hyphen
|
||||||
slug = string.gsub(/[^a-z0-9]+/i, '-')
|
.gsub(/[^a-z0-9]+/i, '-') \
|
||||||
# Remove leading/trailing hyphen
|
# Remove leading/trailing hyphen
|
||||||
slug.gsub!(/^\-|\-$/i, '')
|
.gsub(/^\-|\-$/i, '') \
|
||||||
slug.downcase
|
# Downcase it
|
||||||
|
.downcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue