Class: DocsUI::MarkdownAction
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- DocsUI::MarkdownAction
- Defined in:
- app/components/docs_ui/markdown_action.rb
Overview
The "Markdown" masthead affordance: a link to the current page's .md twin.
With JS off it simply opens the raw Markdown (a working, no-JS fallback); the
docs-nav controller enhances the click into copy-to-clipboard (a new target +
action on the ONE controller — the single-controller rule holds).
render DocsUI::MarkdownAction.new(request.path)
Rendered by DocsUI::Page when DocsKit.configuration.page_markdown_action is
true (the default). The .md twin itself is produced by
DocsKit::Controller#render_page → DocsKit::MarkdownExport.
Constant Summary collapse
- LABEL =
"Markdown"- CLASSES =
"btn btn-ghost btn-xs gap-1 opacity-70 hover:opacity-100"
Instance Method Summary collapse
-
#initialize(path) ⇒ MarkdownAction
constructor
A new instance of MarkdownAction.
- #view_template ⇒ Object
Constructor Details
#initialize(path) ⇒ MarkdownAction
Returns a new instance of MarkdownAction.
18 19 20 |
# File 'app/components/docs_ui/markdown_action.rb', line 18 def initialize(path) @path = path.to_s end |
Instance Method Details
#view_template ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/docs_ui/markdown_action.rb', line 22 def view_template a( href: md_href, class: CLASSES, # JS-ON: docs-nav intercepts the click, fetches the .md, copies it, and # (because the browser default is prevented) never navigates away. data: { docs_nav_target: "markdownLink", action: "docs-nav#copyMarkdown" } ) do render DocsUI::Icon.new("clipboard", class: "size-3.5") plain LABEL end end |