Class: JekyllSupport::OutlineTag

Inherits:
JekyllBlock
  • Object
show all
Includes:
JekyllOutlineVersion
Defined in:
lib/outline_tag.rb

Constant Summary

Constants included from JekyllOutlineVersion

JekyllOutlineVersion::VERSION

Instance Method Summary collapse

Instance Method Details

#render_impl(text) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/outline_tag.rb', line 17

def render_impl(text)
  block_content = super # Process the block content.

  @helper.gem_file __FILE__ # For attribution

  @die_on_outline_error = @tag_config['die_on_outline_error'] == true if @tag_config
  @pry_on_outline_error = @tag_config['pry_on_outline_error'] == true if @tag_config

  pattern = @helper.parameter_specified?('pattern')&.split ||
            @helper.parameter_specified?('fields')&.split ||
            ['title']
  sort_by = @helper.parameter_specified?('sort_by_title') ? :title : :order
  collection_name = @helper.remaining_markup
  raise OutlineError, 'collection_name was not specified' unless collection_name

  outline_options = OutlineOptions.new(
    attribution:        @attribution,
    collection_name:    collection_name,
    enable_attribution: @attribution,
    pattern:            pattern,
    sort_by:            sort_by
  )
  yaml_parser = YamlParser.new outline_options, block_content
  outline = Outline.new(outline_options: outline_options)
  outline.add_sections yaml_parser.sections

  abort "#{collection_name} is not a valid collection." unless @site.collections&.key?(collection_name)
  docs = @site
         .collections[collection_name]
         .docs
  outline.add_entries(collection_apages(docs))
  outline.to_s
rescue OutlineError => e # jekyll_plugin_support handles StandardError
  @logger.error { JekyllPluginHelper.remove_html_tags e.logger_message }
  binding.pry if @pry_on_outline_error # rubocop:disable Lint/Debugger
  exit! 1 if @die_on_outline_error

  e.html_message
end