Class: IndexPage
- Inherits:
-
Object
- Object
- IndexPage
- Defined in:
- lib/ratatui_ruby/devtools/tasks/website/index_page.rb
Overview
Landing page for multi-version documentation portals.
Documentation websites need a version picker. Users land on the portal and choose their version. Without a landing page, they’d need to guess the URL.
This class generates an index page with version links and optional branding. It marks the newest tagged release as “(latest)”.
Use it to build the root index.html for documentation portals.
Instance Method Summary collapse
-
#initialize(versions, branding: {}) ⇒ IndexPage
constructor
Creates an IndexPage.
-
#publish_to(path, project_name:) ⇒ Object
Renders the landing page HTML to a file.
Constructor Details
#initialize(versions, branding: {}) ⇒ IndexPage
Creates an IndexPage.
Marks the newest Tagged version as latest for display.
- versions
-
Array of Version objects.
- branding
-
Optional hash of branding overrides for the template.
27 28 29 30 31 32 33 |
# File 'lib/ratatui_ruby/devtools/tasks/website/index_page.rb', line 27 def initialize(versions, branding: {}) @versions = versions @branding = branding latest_version = @versions.find { |v| v.is_a?(Tagged) } latest_version.is_latest = true if latest_version end |
Instance Method Details
#publish_to(path, project_name:) ⇒ Object
Renders the landing page HTML to a file.
Uses an ERB template with version links and branding.
- path
-
Output file path.
- project_name
-
Project name for page title.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ratatui_ruby/devtools/tasks/website/index_page.rb', line 41 def publish_to(path, project_name:) puts "Generating index page..." template_path = File.("../resources/index.html.erb", __dir__) template = File.read(template_path) versions = @versions branding = @branding # project_name is used in the ERB html_content = ERB.new(template).result(binding) File.write(path, html_content) end |