/
config.rb
35 lines (30 loc) · 1.32 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'govuk_tech_docs'
# Check for broken links
require 'html-proofer'
require_relative 'test'
# Pretty URLs see https://middlemanapp.com/advanced/pretty-urls/
activate :directory_indexes
GovukTechDocs.configure(self)
page "/*", :layout => "dicustom_layout"
after_build do |builder|
begin
HTMLProofer.check_directory(config[:build_dir],
{ :assume_extension => true,
:allow_hash_href => true,
:ignore_files => [
/search/ # Provided by tech-docs gem but has a "broken" link from html-proofer's point of view
],
:ignore_urls => [
/#{Regexp.quote(config[:tech_docs][:github_repo])}/, # Avoid chicken-and-egg problem when new pages in a PR break the link checker
"https://ico.org.uk/for-organisations/guide-to-data-protection/guide-to-the-general-data-protection-regulation-gdpr/data-protection-impact-assessments-dpias/" # Avoid flagging checker because of CloudFlare security on site
],
:swap_urls => { config[:tech_docs][:host] => "" },
typhoeus: {
# Some external links need to think you're in a browser to serve non-error codes
headers: { "User-Agent" => "Mozilla/5.0 (Android 14; Mobile; LG-M255; rv:122.0) Gecko/122.0 Firefox/122.0" }
}
}).run
rescue RuntimeError => e
abort e.to_s
end
end