Class: BridgetownContentSecurityPolicy::Builder

Inherits:
Bridgetown::Builder
  • Object
show all
Defined in:
lib/bridgetown-content-security-policy/builder.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bridgetown-content-security-policy/builder.rb', line 11

def build
  require_relative site.in_root_dir("config", "content_security_policy.config.rb")

  unless default_policy
    # rubocop:disable Layout/LineLength
    Bridgetown.logger.error "\nDefault Content Security Policy not configured"
    Bridgetown.logger.info "Please configure a default CSP in content_security_policy.config.rb\n"
    # rubocop:enable Layout/LineLength
  end

  liquid_tag "content_security_policy" do |_attributes, tag|
    render tag.context["page"]["content_security_policy"]
  end

  helper "content_security_policy" do
    render helpers.view.page.data.content_security_policy
  end
end