Class: DocsUI::MetaTags

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Phlex::Rails::Helpers::ImageURL, Phlex::Rails::Helpers::Request
Defined in:
app/components/docs_ui/meta_tags.rb

Overview

The SEO / social-share tags: description, Open Graph, Twitter Card, canonical, favicon, robots, theme-color. Rendered by DocsUI::Shell inside

, driven entirely by DocsKit.configuration (+ .seo) and the per-page title/description — so every docs site is share-ready with zero markup, and a site tunes it through config alone (no Shell subclass).
render DocsUI::MetaTags.new(title: "Installation", description: "")

All free text (title, description, brand) is emitted as normal Phlex attribute values, so Phlex escapes it — config free text is never trusted markup. The og:image is SITE content (nil by default → no og:image tag): a relative og_image is resolved through the SITE'S asset pipeline (image_url) to the DIGESTED /assets URL Propshaft serves — NOT the raw config path, which 404s; an absolute URL passes through. canonical/og:url come from config.seo.site_url, else the request URL; both are omitted off a request (guarded like Shell#csp_nonce, so an isolated render never raises).

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, description: nil) ⇒ MetaTags

title: the page title (nil on a page that sets none, e.g. the home page) — combined with config.title_suffix for og:title. description: the page's resolved description (DocsUI::Page passes its own description or #lead); nil falls back to config.seo.description.



28
29
30
31
# File 'app/components/docs_ui/meta_tags.rb', line 28

def initialize(title: nil, description: nil)
  @title = title
  @description = description
end

Instance Method Details

#view_templateObject



33
34
35
36
37
38
39
40
41
# File 'app/components/docs_ui/meta_tags.rb', line 33

def view_template
  description_meta
  open_graph
  twitter_card
  canonical_link
  favicon_link
  robots_meta
  theme_color_meta
end