This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-69
lines changed Expand file tree Collapse file tree 3 files changed +30
-69
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # The hook runs html-proofer with options defined in the
2
+ # _checks/html-check-config.yml file
3
+ #
4
+ # For more details about html-proofer, refer to: https://github.com/gjtorikian/html-proofer
5
+ # For more details about Jekyll hooks, refer to: https://jekyllrb.com/docs/plugins/hooks/
6
+ #
7
+ require 'html-proofer'
8
+ require 'yaml'
9
+
10
+ Jekyll ::Hooks . register :site , :post_write do |site |
11
+
12
+ # If 'jekyll serve' has been run, read options for html-proofer
13
+ # in '_config.checks.yml' and merge the 'url_ignore' list with 'excludes'
14
+ # from Jekyll configurtiuon
15
+ #
16
+ if site . config [ 'serving' ] == true
17
+ begin
18
+ checks_config = YAML . load_file ( '_config.checks.yml' )
19
+ jekyll_excludes = site . config [ 'exclude' ]
20
+ jekyll_excludes_as_regex = jekyll_excludes . map { |item | /#{ item } / }
21
+ checks_config [ 'html-proofer' ] [ :url_ignore ] . push ( jekyll_excludes_as_regex ) . flatten! . uniq!
22
+ options = checks_config [ 'html-proofer' ]
23
+ # Run html-proofer to check the jekyll destination directory
24
+ HTMLProofer . check_directory ( site . dest , options ) . run
25
+ rescue
26
+ puts
27
+ puts 'Fix the broken links before you commit the changes.' . blue
28
+ end
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments