Class: Kitchen::Directions::BakeReferences::V2

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_references/v2.rb

Instance Method Summary collapse

Instance Method Details

#bake(book:, metadata_source:) ⇒ Object



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
# File 'lib/kitchen/directions/bake_references/v2.rb', line 5

def bake(book:, metadata_source:)
  book.chapters.each do |chapter|

    chapter.references.search('h3').trash

    chapter_references = chapter.pages.references.cut
    chapter_title_no_num = chapter.title.search('.os-text')

    chapter.append(child:
      <<~HTML
        <div class="os-chapter-area">
          <h2 data-type="document-title">#{chapter_title_no_num}</h2>
          #{chapter_references.paste}
        </div>
      HTML
    )
  end

  chapter_area_references = book.chapters.search('.os-chapter-area').cut

  Kitchen::Directions::CompositePageContainer.v1(
    container_key: 'references',
    uuid_key: '.references',
    metadata_source: ,
    content: chapter_area_references.paste,
    append_to: book.body
  )
end