Class: DocsKit::LandingConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/docs_kit/landing_config.rb

Overview

The per-site landing-page knobs, read by DocsUI::Landing to render a marketing home page (hero + feature grid + doc index) without a site hand-rolling one. Nested under DocsKit::Configuration#landing so a site configures it as a block:

DocsKit.configure do |c|
c.landing.eyebrow = "Developer Docs"
c.landing.title   = "Jobs & events on Postgres"   # highlight a run with **…**
c.landing.lead    = "PostgreSQL-native job processing and event bus for Rails."
c.landing.install = { code: 'gem "pgbus"', filename: "Gemfile", lexer: :ruby }
c.landing.ctas = [
  { label: "Get started", href: "/docs/overview", style: :primary },
  { label: "GitHub",      href: "https://github.com/me/repo", style: :ghost, icon: :github },
]
c.landing.features = [
  { icon: "database", title: "One database", body: "No Redis, no broker." },
  { icon: "zap",      title: "Fast",         body: "" },
]
end

Every field is optional and defaults to a backwards-safe value: a site that sets none still renders a minimal hero (the brand + a doc index), never a broken page. Plain accessors (not Data.define) because each field is individually assignable in the c.landing.x = ... block, mirroring DocsKit::SeoConfig.

Defined Under Namespace

Classes: Cta, Feature, Logo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLandingConfig

Returns a new instance of LandingConfig.



65
66
67
68
69
# File 'lib/docs_kit/landing_config.rb', line 65

def initialize
  @doc_index = true
  @ctas = []
  @features = []
end

Instance Attribute Details

#ctasObject

The CTAs as normalized Cta value objects (empty when unset).



75
76
77
# File 'lib/docs_kit/landing_config.rb', line 75

def ctas
  Array(@ctas).map { |cta| Cta.from(cta) }
end

#doc_index=(value) ⇒ Object (writeonly)

Whether to render the registry-grouped documentation index below the hero (the "Documentation" section linking every authored page). Default true.



55
56
57
# File 'lib/docs_kit/landing_config.rb', line 55

def doc_index=(value)
  @doc_index = value
end

#eyebrowObject

A small uppercase kicker above the title (e.g. "Developer Docs"). nil omits it.



39
40
41
# File 'lib/docs_kit/landing_config.rb', line 39

def eyebrow
  @eyebrow
end

#featuresObject

The features as normalized Feature value objects (empty when unset).



80
81
82
# File 'lib/docs_kit/landing_config.rb', line 80

def features
  Array(@features).map { |feature| Feature.from(feature) }
end

#installObject

An optional install/quickstart code block shown in the hero, as a Hash:

{ code: "gem \"x\"", filename: "Gemfile", lexer: :ruby }

nil omits the block. See #install_snippet for the normalized form.



51
52
53
# File 'lib/docs_kit/landing_config.rb', line 51

def install
  @install
end

#leadObject

The muted lead paragraph under the title. nil falls back to the tagline.



46
47
48
# File 'lib/docs_kit/landing_config.rb', line 46

def lead
  @lead
end

#logo=(value) ⇒ Object (writeonly)

An optional brand logo/mark rendered at the top of the hero (above the eyebrow), like a product wordmark. A Hash in one of two forms:

{ svg: "<path d …>", viewbox: "0 0 81 45", label: "Brand" }  # inline mark
{ src: "logo.svg", alt: "Brand" }                            # image asset/URL

The inline svg form renders with fill: currentColor so it adapts to the theme (light/dark) — best for a single-color mark. nil omits the logo. See #hero_logo (the normalized Logo value object) and DocsUI::Landing.



36
37
38
# File 'lib/docs_kit/landing_config.rb', line 36

def logo=(value)
  @logo = value
end

#titleObject

The hero

. Wrap a run in double asterisks to render it in the primary color (e.g. "Jobs & events on Postgres"). nil falls back to the brand.



43
44
45
# File 'lib/docs_kit/landing_config.rb', line 43

def title
  @title
end

Instance Method Details

#doc_index?Boolean

Whether the doc index is shown (default true).

Returns:

  • (Boolean)


72
# File 'lib/docs_kit/landing_config.rb', line 72

def doc_index? = @doc_index != false

#hero_logoObject

The hero logo as a normalized Logo value object, or nil when unset.



94
95
96
97
98
# File 'lib/docs_kit/landing_config.rb', line 94

def 
  return if @logo.nil?

  Logo.from(@logo)
end

#install_snippetObject

The install block normalized to { code:, filename:, lexer: } with a sensible default lexer, or nil when unset.



86
87
88
89
90
91
# File 'lib/docs_kit/landing_config.rb', line 86

def install_snippet
  return if @install.nil?

  attrs = @install.to_h.transform_keys(&:to_sym)
  { code: attrs[:code].to_s, filename: attrs[:filename], lexer: (attrs[:lexer] || :shell).to_sym }
end