Class: Jekyll::LlmsOutput::IndexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-llms-output/index_builder.rb

Overview

Builds the body of /llms.txt.

Two modes:

1. Data-driven: site.data[<key>] holds a hash with title / description /
   sections. The plugin renders that structure to llmstxt.org format.
2. Auto: no data hash present. The plugin generates one section per
   configured collection with a bullet for each document.

llmstxt.org spec we follow:

# Title
> Optional one-line description
## Section heading
- [Title](url): optional description

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, options) ⇒ IndexBuilder

Returns a new instance of IndexBuilder.



21
22
23
24
# File 'lib/jekyll-llms-output/index_builder.rb', line 21

def initialize(site, options)
  @site = site
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/jekyll-llms-output/index_builder.rb', line 19

def options
  @options
end

#siteObject (readonly)

Returns the value of attribute site.



19
20
21
# File 'lib/jekyll-llms-output/index_builder.rb', line 19

def site
  @site
end

Instance Method Details

#buildObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/jekyll-llms-output/index_builder.rb', line 26

def build
  data_key = options["data"]
  data_hash = data_key && site.data[data_key.to_s]

  if data_hash.is_a?(Hash) && data_hash["sections"]
    render_from_data(data_hash)
  else
    render_auto
  end
end