Sha256: 375673e3060714873fd7c69d93ec20953880a124294e631fca94123eaa217830
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true module Kitchen::Directions::BakeChapterIntroductions class BakeChapterObjectives def bake(chapter:, strategy:) case strategy when :default bake_as_note(chapter: chapter) when :add_objectives add_chapter_objectives(chapter: chapter) when :none '' else raise 'No such strategy' end end def bake_as_note(chapter:) chapter_objectives_note = chapter.notes('$.chapter-objectives').first # trash existing title chapter_objectives_note.titles.first&.trash Kitchen::Directions::BakeAutotitledNotes.v1( book: chapter, classes: %w[chapter-objectives], bake_subtitle: false ) chapter_objectives_note.cut.paste end def add_chapter_objectives(chapter:) chapter.non_introduction_pages.map do |page| <<~HTML <div class="os-chapter-objective"> <a class="os-chapter-objective" href="##{page.title[:id]}"> <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span> <span class="os-divider"> </span> <span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span> </a> </div> HTML end.join('') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openstax_kitchen-11.1.0 | lib/kitchen/directions/bake_chapter_introductions/bake_chapter_objectives.rb |