Class: Willamette::Builders::Inspectors
- Inherits:
-
Bridgetown::Builder
- Object
- Bridgetown::Builder
- Willamette::Builders::Inspectors
- Defined in:
- lib/willamette/builders/inspectors.rb
Instance Method Summary collapse
-
#build ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Instance Method Details
#build ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/willamette/builders/inspectors.rb', line 3 def build # rubocop:disable Metrics/CyclomaticComplexity inspect_html do |document| document.query_selector_all("a").each do |anchor| next if anchor[:target] unless anchor[:href]&.starts_with?("http") && !anchor[:href]&.include?(site.config.url) next end anchor[:target] = "_blank" end end inspect_html do |document| document.query_selector_all("article h2[id], article h3[id]").each do |heading| heading << document.create_text_node(" ") heading << document.create_element( "a", "#", href: "##{heading[:id]}", class: "heading-anchor" ) end end end |