Class: Helios::Seo::Configuration
- Inherits:
-
Object
- Object
- Helios::Seo::Configuration
- Defined in:
- lib/helios/seo/configuration.rb
Overview
Central configuration for helios-seo. Every value has a safe default and every resolver is an individually-overridable callable that receives the content resource, so the host controls behavior without schema changes.
Instance Attribute Summary collapse
-
#author ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
-
#breadcrumb_blog ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
-
#canonical_url ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------.
-
#default_description ⇒ Object
--- Site identity -----------------------------------------------------.
-
#default_og_image ⇒ Object
--- Site identity -----------------------------------------------------.
-
#faq_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------.
-
#image_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------.
-
#llms_description ⇒ Object
--- llms.txt ----------------------------------------------------------.
-
#llms_posts ⇒ Object
--- llms.txt ----------------------------------------------------------.
-
#publisher_type ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
-
#robots_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------.
-
#site_name ⇒ Object
--- Site identity -----------------------------------------------------.
-
#site_url ⇒ Object
--- Site identity -----------------------------------------------------.
-
#title_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------.
-
#title_template ⇒ Object
--- Site identity -----------------------------------------------------.
-
#twitter_creator ⇒ Object
--- Social handles ----------------------------------------------------.
-
#twitter_site ⇒ Object
--- Social handles ----------------------------------------------------.
Instance Method Summary collapse
-
#default_canonical_url(resource) ⇒ Object
Default canonical: "#site_url/slug".
-
#default_robots(resource) ⇒ Object
Default robots: index published resources, hide everything else.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/helios/seo/configuration.rb', line 36 def initialize @site_name = nil @site_url = nil @title_template = "%{title} — %{site_name}" @default_description = nil @default_og_image = nil @twitter_site = nil @twitter_creator = nil @publisher_type = :person @author = {} @breadcrumb_blog = nil # e.g. { name: "Blog", url: "https://site/blog" } # Resolvers — all have safe defaults, all overridable. @canonical_url = ->(resource) { default_canonical_url(resource) } @robots_resolver = ->(resource) { default_robots(resource) } @title_resolver = ->(_resource) { nil } # return a String to override the template @image_resolver = ->(_resource) { nil } # return an image URL; falls back to default_og_image @faq_resolver = ->(_resource) { [] } # return [{ question:, answer: }] to emit FAQPage # llms.txt @llms_description = nil # falls back to default_description @llms_posts = -> { [] } # return an enumerable of published resources end |
Instance Attribute Details
#author ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
21 22 23 |
# File 'lib/helios/seo/configuration.rb', line 21 def @author end |
#breadcrumb_blog ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
21 22 23 |
# File 'lib/helios/seo/configuration.rb', line 21 def @breadcrumb_blog end |
#canonical_url ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------
26 27 28 |
# File 'lib/helios/seo/configuration.rb', line 26 def canonical_url @canonical_url end |
#default_description ⇒ Object
--- Site identity -----------------------------------------------------
8 9 10 |
# File 'lib/helios/seo/configuration.rb', line 8 def default_description @default_description end |
#default_og_image ⇒ Object
--- Site identity -----------------------------------------------------
8 9 10 |
# File 'lib/helios/seo/configuration.rb', line 8 def default_og_image @default_og_image end |
#faq_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------
26 27 28 |
# File 'lib/helios/seo/configuration.rb', line 26 def faq_resolver @faq_resolver end |
#image_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------
26 27 28 |
# File 'lib/helios/seo/configuration.rb', line 26 def image_resolver @image_resolver end |
#llms_description ⇒ Object
--- llms.txt ----------------------------------------------------------
33 34 35 |
# File 'lib/helios/seo/configuration.rb', line 33 def llms_description @llms_description end |
#llms_posts ⇒ Object
--- llms.txt ----------------------------------------------------------
33 34 35 |
# File 'lib/helios/seo/configuration.rb', line 33 def llms_posts @llms_posts end |
#publisher_type ⇒ Object
--- Publisher / author (E-E-A-T) ------------------------------------- publisher_type: :person reuses the author node as publisher; :organization emits a separate Organization node.
21 22 23 |
# File 'lib/helios/seo/configuration.rb', line 21 def publisher_type @publisher_type end |
#robots_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------
26 27 28 |
# File 'lib/helios/seo/configuration.rb', line 26 def robots_resolver @robots_resolver end |
#site_name ⇒ Object
--- Site identity -----------------------------------------------------
8 9 10 |
# File 'lib/helios/seo/configuration.rb', line 8 def site_name @site_name end |
#site_url ⇒ Object
--- Site identity -----------------------------------------------------
8 9 10 |
# File 'lib/helios/seo/configuration.rb', line 8 def site_url @site_url end |
#title_resolver ⇒ Object
--- Resolvers (callables receiving the resource) ----------------------
26 27 28 |
# File 'lib/helios/seo/configuration.rb', line 26 def title_resolver @title_resolver end |
#title_template ⇒ Object
--- Site identity -----------------------------------------------------
8 9 10 |
# File 'lib/helios/seo/configuration.rb', line 8 def title_template @title_template end |
#twitter_creator ⇒ Object
--- Social handles ----------------------------------------------------
15 16 17 |
# File 'lib/helios/seo/configuration.rb', line 15 def twitter_creator @twitter_creator end |
#twitter_site ⇒ Object
--- Social handles ----------------------------------------------------
15 16 17 |
# File 'lib/helios/seo/configuration.rb', line 15 def twitter_site @twitter_site end |
Instance Method Details
#default_canonical_url(resource) ⇒ Object
Default canonical: "#site_url/slug". Kept public so resolvers/ presenters can fall back to it when a custom builder returns nil.
64 65 66 67 68 |
# File 'lib/helios/seo/configuration.rb', line 64 def default_canonical_url(resource) base = site_url.to_s.chomp("/") slug = resource.respond_to?(:slug) ? resource.slug : nil slug.present? ? "#{base}/#{slug}" : base end |
#default_robots(resource) ⇒ Object
Default robots: index published resources, hide everything else.
71 72 73 74 |
# File 'lib/helios/seo/configuration.rb', line 71 def default_robots(resource) published = resource.respond_to?(:published?) ? resource.published? : true published ? "index, follow" : "noindex, nofollow" end |