Class: DocsKit::LandingConfig
- Inherits:
-
Object
- Object
- DocsKit::LandingConfig
- 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
Instance Attribute Summary collapse
-
#ctas ⇒ Object
The CTAs as normalized Cta value objects (empty when unset).
-
#doc_index ⇒ Object
writeonly
Whether to render the registry-grouped documentation index below the hero (the "Documentation" section linking every authored page).
-
#eyebrow ⇒ Object
A small uppercase kicker above the title (e.g. "Developer Docs").
-
#features ⇒ Object
The features as normalized Feature value objects (empty when unset).
-
#install ⇒ Object
An optional install/quickstart code block shown in the hero, as a Hash: { code: "gem "x"", filename: "Gemfile", lexer: :ruby } nil omits the block.
-
#lead ⇒ Object
The muted lead paragraph under the title.
-
#logo ⇒ Object
writeonly
An optional brand logo/mark rendered at the top of the hero (above the eyebrow), like a product wordmark.
-
#title ⇒ Object
The hero
.
Instance Method Summary collapse
-
#doc_index? ⇒ Boolean
Whether the doc index is shown (default true).
-
#hero_logo ⇒ Object
The hero logo as a normalized Logo value object, or nil when unset.
-
#initialize ⇒ LandingConfig
constructor
A new instance of LandingConfig.
-
#install_snippet ⇒ Object
The install block normalized to { code:, filename:, lexer: } with a sensible default lexer, or nil when unset.
Constructor Details
#initialize ⇒ LandingConfig
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
#ctas ⇒ Object
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 |
#eyebrow ⇒ Object
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 |
#features ⇒ Object
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 |
#install ⇒ Object
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 |
#lead ⇒ Object
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 |
#title ⇒ Object
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).
72 |
# File 'lib/docs_kit/landing_config.rb', line 72 def doc_index? = @doc_index != false |
#hero_logo ⇒ Object
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 hero_logo return if @logo.nil? Logo.from(@logo) end |
#install_snippet ⇒ Object
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 |