Empty permalink now shows an error
This commit is contained in:
parent
9368e261cc
commit
f8a63157d7
|
@ -61,6 +61,10 @@ module Jekyll
|
||||||
Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
|
Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless valid_permalink?(self.data['permalink'])
|
||||||
|
Jekyll.logger.error "Error:", "Invalid permalink in #{File.join(base, name)}"
|
||||||
|
end
|
||||||
|
|
||||||
self.data
|
self.data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -266,6 +270,15 @@ module Jekyll
|
||||||
Jekyll::Hooks.trigger hook_owner, :post_render, self
|
Jekyll::Hooks.trigger hook_owner, :post_render, self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check data permalink
|
||||||
|
#
|
||||||
|
# permalink - the data permalink
|
||||||
|
#
|
||||||
|
# Returns true if the permalink is valid, false if otherwise
|
||||||
|
def valid_permalink?(permalink)
|
||||||
|
permalink.nil? || permalink.length > 0
|
||||||
|
end
|
||||||
|
|
||||||
# Write the generated page file to the destination directory.
|
# Write the generated page file to the destination directory.
|
||||||
#
|
#
|
||||||
# dest - The String path to the destination dir.
|
# dest - The String path to the destination dir.
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
permalink: ''
|
||||||
|
---
|
||||||
|
Empty Permalink
|
|
@ -49,5 +49,14 @@ class TestConvertible < JekyllUnitTest
|
||||||
assert_match(/invalid byte sequence in UTF-8/, out)
|
assert_match(/invalid byte sequence in UTF-8/, out)
|
||||||
assert_match(/#{File.join(@base, name)}/, out)
|
assert_match(/#{File.join(@base, name)}/, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "parse the front-matter but show an error if permalink is empty" do
|
||||||
|
name = 'empty_permalink.erb'
|
||||||
|
out = capture_stderr do
|
||||||
|
@convertible.read_yaml(@base, name)
|
||||||
|
end
|
||||||
|
assert_match(/Invalid permalink/, out)
|
||||||
|
assert_match(/#{File.join(@base, name)}/, out)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue