Class: DocsUI::ArchivedPage

Inherits:
Phlex::HTML
  • Object
show all
Includes:
DocsUI
Defined in:
app/components/docs_ui/archived_page.rb

Overview

Renders one page of an ARCHIVED documentation version — a frozen Markdown body (DocsKit::Snapshot::Entry) through today's live chrome, so archived docs get every future Shell/Sidebar/Code fix for free. The live counterpart is DocsUI::Page; this mirrors its shape with the content coming from the snapshot file instead of an authored #content method.

Every kwarg defaults, so even a naive entry.view_class.new (a custom registry predating #renderable) renders an empty page rather than raising.

NOTE (issue #61 phase 4): the "you are viewing the 1.0 docs" banner with a link to the current equivalent lands with the version switcher, not here.

Deliberately does NOT include Phlex::Rails::Helpers::Routes/Request — their bodies run Rails.* at class load, which would make this class (and everything referencing it, like Snapshot::Entry#view_class) unloadable in a Rails-free render. Nothing here needs a request.

Instance Method Summary collapse

Constructor Details

#initialize(entry: nil) ⇒ ArchivedPage

Returns a new instance of ArchivedPage.



23
24
25
# File 'app/components/docs_ui/archived_page.rb', line 23

def initialize(entry: nil)
  @entry = entry
end

Instance Method Details

#bodyObject

The masthead + Markdown body — separated from the Shell wrapper so it can render (and be specced) without a Rails view context, the same seam as Shell's own topbar/theme-script specs.



34
35
36
37
# File 'app/components/docs_ui/archived_page.rb', line 34

def body
  render DocsUI::Header.new(@entry.title) if @entry&.title
  render DocsUI::Markdown.new(markdown_source) unless markdown_source.empty?
end

#view_templateObject



27
28
29
# File 'app/components/docs_ui/archived_page.rb', line 27

def view_template
  render DocsUI::Shell.new(title: @entry&.title) { body }
end