Class: Kitchen::Directions::BakeReferences::V3

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_references/v3.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
# File 'lib/kitchen/directions/bake_references/v3.rb', line 5

def bake(book:, metadata_source:)
  return unless book.references.any?

  book.chapters.pages.each do |page|
    page.references.each do |reference|
      reference.titles.trash
      reference.prepend(child:
        Kitchen::Directions::EocSectionTitleLinkSnippet.v1(
          page: page,
          title_tag: 'h2',
          wrapper: nil
        )
      )
    end
  end

  chapter_area_references = book.chapters.references.cut

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