You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,11 +44,11 @@ This check ensures that any listed variables exist in the front matter of any po
44
44
45
45
#### FrontMatterVariableIsNotDuplicate
46
46
47
-
This check ensures that any listed variable in the front matter of any post that is staged to be committed are unique amongst all the posts on your site.
47
+
This check ensures that any listed variables are unique amongst all the posts on your site in the front matter of any post that is staged to be committed.
48
48
49
49
#### FrontMatterVariableMeetsLengthRequirements
50
50
51
-
This check ensures that any listed variable in the front matter of any post that is staged to be committed meet the length requirements (in number of characters).
51
+
This check ensures that any listed variables meet the length requirements (in number of characters) in the front matter of any post that is staged to be committed.
52
52
53
53
This check includes the following defaults:
54
54
@@ -74,6 +74,35 @@ For example...
74
74
75
75
In the above, there would be a maximum length of 50 characters for the title (rather than the default of 59)
76
76
77
+
## Roll Your Own
78
+
79
+
You can also add your own checks. To do so, create a class in the `Jekyll::PreCommit::Check` module and and define a `check` method. Your class should extend the `Jekyll::PreCommit::Check::Check` class and return the `@result` instance variable.
80
+
81
+
For example...
82
+
83
+
```ruby
84
+
module Jekyll
85
+
module PreCommit
86
+
module Check
87
+
class DoesNothing < Check
88
+
def check(staged, not_staged, site, args)
89
+
@result
90
+
end
91
+
end
92
+
end
93
+
end
94
+
end
95
+
```
96
+
97
+
Put this file in your plugins_path (which is _plugins by default) and `jekyll-pre-commit` will load it automatically. Then just specify that you'd like to run this check in your front matter.
98
+
99
+
```yaml
100
+
pre-commit:
101
+
- check: DoesNothing
102
+
```
103
+
104
+
As you can probably tell by the name, this check doesn't actually do anything. Review the checks in `lib/jekyll-pre-commit/checks` for some more useful examples.
105
+
77
106
## Contributing
78
107
79
108
Bug reports and pull requests are welcome on GitHub at https://github.com/mpchadwick/jekyll-pre-commit.
0 commit comments