Class: DocsKit::SeoConfig
- Inherits:
-
Object
- Object
- DocsKit::SeoConfig
- Defined in:
- lib/docs_kit/seo_config.rb
Overview
The per-site SEO / social-share knobs, read by DocsUI::MetaTags to emit the
meta/link tags (description, Open Graph, Twitter Card, canonical, favicon, theme-color). Nested under DocsKit::Configuration#seo so a site configures it as a small block:DocsKit.configure do |c|
c.seo.description = "What these docs cover, in one sentence."
c.seo.og_image = "og/og.png" # generated by `bin/rails docs_kit:og`
c.seo.twitter_site = "@my_handle"
end
Every field defaults to a backwards-safe value: a site that sets none still
renders a valid minimal Open Graph block and no broken empty tags. Plain
accessors (not Data.define) because each field is individually assignable in
the c.seo.x = ... block, mirroring DocsKit::Configuration's own style.
Instance Attribute Summary collapse
-
#description ⇒ Object
A one-line page/site description → and og:description / twitter:description.
-
#favicon ⇒ Object
A robots directive (e.g. "noindex, nofollow") → .
-
#locale ⇒ Object
The og:locale (e.g. "en_US", "sv_SE").
-
#og_image ⇒ Object
The social-share image → og:image / twitter:image.
-
#og_type ⇒ Object
The og:type.
-
#robots ⇒ Object
A favicon asset path/URL → .
-
#site_url ⇒ Object
The site's canonical base URL (e.g. "https://docs.example.com").
-
#theme_color ⇒ Object
A theme-color (e.g. "#0f172a") → , tinting mobile browser chrome.
-
#twitter_card ⇒ Object
The twitter:card style.
-
#twitter_creator ⇒ Object
The site's @handle → twitter:site, and the content author's → twitter:creator.
-
#twitter_site ⇒ Object
The site's @handle → twitter:site, and the content author's → twitter:creator.
Instance Method Summary collapse
-
#initialize ⇒ SeoConfig
constructor
A new instance of SeoConfig.
Constructor Details
#initialize ⇒ SeoConfig
Returns a new instance of SeoConfig.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/docs_kit/seo_config.rb', line 67 def initialize @description = nil @og_image = nil @og_type = "website" @twitter_card = "summary_large_image" @twitter_site = nil @twitter_creator = nil @locale = "en_US" @site_url = nil @robots = nil @favicon = nil @theme_color = nil end |
Instance Attribute Details
#description ⇒ Object
A one-line page/site description → and og:description / twitter:description. nil omits the description tags (DocsUI::Page derives a per-page value from #lead when a page sets none).
23 24 25 |
# File 'lib/docs_kit/seo_config.rb', line 23 def description @description end |
#favicon ⇒ Object
A robots directive (e.g. "noindex, nofollow") → . nil omits the tag, so the page is indexable by default.
57 58 59 |
# File 'lib/docs_kit/seo_config.rb', line 57 def favicon @favicon end |
#locale ⇒ Object
The og:locale (e.g. "en_US", "sv_SE").
46 47 48 |
# File 'lib/docs_kit/seo_config.rb', line 46 def locale @locale end |
#og_image ⇒ Object
The social-share image → og:image / twitter:image. Either a logical asset
path in the SITE'S OWN pipeline (e.g. "og/og.png", resolved through
image_url to the digested /assets URL Propshaft serves) or an absolute URL.
The image is SITE content, not shipped by the gem — nil by default, so a
site with no card image emits NO og:image (a valid card, never a 404).
Generate one into app/assets/images/ with bin/rails docs_kit:og, then set
this to its path.
32 33 34 |
# File 'lib/docs_kit/seo_config.rb', line 32 def og_image @og_image end |
#og_type ⇒ Object
The og:type. "website" for a docs site; a page could override to "article".
35 36 37 |
# File 'lib/docs_kit/seo_config.rb', line 35 def og_type @og_type end |
#robots ⇒ Object
A favicon asset path/URL → . nil omits the link (the host may serve /favicon.ico itself).
61 62 63 |
# File 'lib/docs_kit/seo_config.rb', line 61 def robots @robots end |
#site_url ⇒ Object
The site's canonical base URL (e.g. "https://docs.example.com"). When set, og:image/og:url/canonical are absolutized against it even off a request (a static build, an isolated render). nil → DocsUI::MetaTags falls back to the request base URL, and omits canonical/absolute og:url when there's no request either.
53 54 55 |
# File 'lib/docs_kit/seo_config.rb', line 53 def site_url @site_url end |
#theme_color ⇒ Object
A theme-color (e.g. "#0f172a") → , tinting mobile browser chrome. nil omits the tag.
65 66 67 |
# File 'lib/docs_kit/seo_config.rb', line 65 def theme_color @theme_color end |
#twitter_card ⇒ Object
The twitter:card style. "summary_large_image" renders a full-width banner (size your og:image 1200×630 for it); "summary" is the small square card.
39 40 41 |
# File 'lib/docs_kit/seo_config.rb', line 39 def twitter_card @twitter_card end |
#twitter_creator ⇒ Object
The site's @handle → twitter:site, and the content author's → twitter:creator. Both nil by default (a site with no X presence emits neither tag).
43 44 45 |
# File 'lib/docs_kit/seo_config.rb', line 43 def twitter_creator @twitter_creator end |
#twitter_site ⇒ Object
The site's @handle → twitter:site, and the content author's → twitter:creator. Both nil by default (a site with no X presence emits neither tag).
43 44 45 |
# File 'lib/docs_kit/seo_config.rb', line 43 def twitter_site @twitter_site end |