Module: Kitchen::Directions::BakeNonIntroductionPages

Defined in:
lib/kitchen/directions/bake_non_introduction_pages.rb

Class Method Summary collapse

Class Method Details

.v1(chapter:, add_target_label: false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kitchen/directions/bake_non_introduction_pages.rb', line 6

def self.v1(chapter:, add_target_label: false)
  chapter.non_introduction_pages.each do |page|
    number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"

    page.search("div[data-type='description']").each(&:trash)
    page.add_class('chapter-content-module')

    page.target_label(custom_content: number) if add_target_label

    title = page.title
    title.name = 'h2'
    title.replace_children(with:
      <<~HTML
        <span class="os-number">#{number}</span>
        <span class="os-divider"> </span>
        <span data-type="" itemprop="" class="os-text">#{title.text}</span>
      HTML
    )
  end
end