-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathbase.rb
More file actions
47 lines (41 loc) · 1.51 KB
/
base.rb
File metadata and controls
47 lines (41 loc) · 1.51 KB
1
2
3
4
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true
module Jekyll
module Data
module Title
class Base # rubocop:disable Style/Documentation
def self.make_for(page:, site:) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
if page.url.start_with?('/api/')
APIPage.new(page:, site:)
elsif page.url.start_with?('/plugins/')
Plugin.new(page:, site:)
elsif page.url.start_with?('/prompts/')
Prompt.new(page:, site:)
elsif page.url.start_with?('/mesh/policies/') || page.url.start_with?('/event-gateway/policies/')
Policy.new(page:, site:)
elsif page.data['content_type'] && page.data['content_type'] == 'reference'
Reference.new(page:, site:)
elsif page.data['content_type'] && page.data['content_type'] == 'how_to'
HowTo.new(page:, site:)
else
# for plain html pages or pages that don't require anything specific
OpenStruct.new(title_sections: [page.data['title']], llm_title: page.data['title'])
end
end
def initialize(page:, site:)
@page = page
@site = site
end
private
def page_title
@page_title ||= @page.data['title']
end
def product
@product ||= @page.data.fetch('products', []).first
end
def tool
@tool ||= @page.data.fetch('tools', []).first
end
end
end
end
end