jekyll_strict_front_matter 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +7 -0
- data/README.md +21 -0
- data/lib/jekyll_strict_front_matter.rb +23 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6cd43a41318abb600cf58558180d3b7b8ee47fb5
|
4
|
+
data.tar.gz: 6da73ed26fbdae74c4d4385bcae23811399f81e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ae3b00a9e3ed1813534614b09735323ac2cb73b92bafa114ead6e3ebdcd756f4e1104fa216b826006d62f7aa32b979e35939c9bdb791d46a851ebbd10d4e3a8
|
7
|
+
data.tar.gz: 962446c2ad38d7bf278b8f45f3c38399518c2afe434baef362c742b18e78879a765290e8f1e796bbbf13a197e91748253181a08aa23602c82e1b0092a35c948e
|
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2017 Jonathan Hooper
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
By default, if a page or a post in a Jekyll site has a syntax error in the front matter, Jekyll logs an error, does not render anything for the given document, and continues. The result is a site without any content for the page with the syntax errors.
|
2
|
+
|
3
|
+
This can be confusing for people who build sites without looking at the CLI, such as those of us whose sites build in a CI. In these cases, we may wish for our build to fail if there are front matter syntax errors. [This PR](https://github.com/jekyll/jekyll/pull/5832/files) seeks to add a config option for that, but in the meantime this plugin exists to fill the gap. This plugin may also be used to add the option to sites using an older version of Jekyll.
|
4
|
+
|
5
|
+
# Gettings Started
|
6
|
+
|
7
|
+
To use this plugin, first add the plugin to your Gemfile and run `bundle install`.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :jekyll_plugins do
|
11
|
+
gem "jekyll_strict_front_matter"
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
Next, enable `strict_front_matter` by adding the option to your `_config.yml`:
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
strict_front_matter: true
|
19
|
+
```
|
20
|
+
|
21
|
+
Now, a syntax error in the YAML should raise an error, stop the build, and result in a non-zero exit code.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class StrictFrontMatterError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
Hooks.register :documents, :post_init do |document|
|
6
|
+
if !document.site.config["strict_front_matter"]
|
7
|
+
next
|
8
|
+
end
|
9
|
+
|
10
|
+
contents = File.read(document.path)
|
11
|
+
|
12
|
+
match_data = Document::YAML_FRONT_MATTER_REGEXP.match(contents)
|
13
|
+
if match_data
|
14
|
+
yaml = match_data[1]
|
15
|
+
begin
|
16
|
+
SafeYAML.load(yaml)
|
17
|
+
rescue => e
|
18
|
+
Jekyll.logger.error "Error:", "YAML Exception reading #{document.path}: #{e.message}"
|
19
|
+
raise StrictFrontMatterError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_strict_front_matter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Hooper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.5.0
|
27
|
+
description: |2
|
28
|
+
By default, if a page or a post in a Jekyll site has a syntax error in the
|
29
|
+
front matter, Jekyll logs an error, does not render anything for the given
|
30
|
+
page, and continues. The result is a site without any content for the
|
31
|
+
page with the syntax error.
|
32
|
+
|
33
|
+
This can be confusing for people who build sites without looking at the CLI,
|
34
|
+
such as those of us whose sites build in a CI. In these cases, we may wish
|
35
|
+
for our build to fail if there are front matter syntax errors.
|
36
|
+
[This PR](https://github.com/jekyll/jekyll/pull/5832/files) seeks to add a
|
37
|
+
config option for that, but in the meantime this plugin exists to fill the
|
38
|
+
gap. This plugin may also be used to add the option to sites using an older
|
39
|
+
version of Jekyll.
|
40
|
+
email: jon9820@gmail.com
|
41
|
+
executables: []
|
42
|
+
extensions: []
|
43
|
+
extra_rdoc_files: []
|
44
|
+
files:
|
45
|
+
- LICENSE.md
|
46
|
+
- README.md
|
47
|
+
- lib/jekyll_strict_front_matter.rb
|
48
|
+
homepage: http://rubygems.org/gems/jekyll-strict-front-matter
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.6.11
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: A jekyll plugin for raising for YAML front matter syntax errors
|
72
|
+
test_files: []
|