Class: DatoDast::Nodes::Link
- Inherits:
-
Base
- Object
- Base
- DatoDast::Nodes::Link
show all
- Defined in:
- lib/dato_dast/nodes/link.rb
Constant Summary
collapse
- NEW_WINDOW_META =
[
{ "id" => "rel", "value" => "nofollow" },
{ "id" => "target", "value" => "_blank" },
].freeze
Constants inherited
from Base
Base::EMPTY, Base::NEWLINE
Instance Method Summary
collapse
Methods inherited from Base
#children, #config, #css_class, #initialize, #node_config, #render, #render_children, #render_value, #tag, #tag_info, #type, type, #wrappers
Instance Method Details
21
22
23
24
25
26
|
# File 'lib/dato_dast/nodes/link.rb', line 21
def meta
fields = @node["meta"].dup || []
fields.prepend({ "id" => "href", "value" => path })
new_window? ? (fields + NEW_WINDOW_META).uniq : fields
end
|
#path ⇒ Object
28
29
30
|
# File 'lib/dato_dast/nodes/link.rb', line 28
def path
local_url || uri.to_s
end
|
#url ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/dato_dast/nodes/link.rb', line 11
def url
node_url = @node["url"]
if node_url =~ URI::MailTo::EMAIL_REGEXP
"mailto:#{node_url}"
else
node_url
end
end
|