lib/storyblok/richtext/html_renderer/marks/link.rb in storyblok-richtext-renderer-0.0.5 vs lib/storyblok/richtext/html_renderer/marks/link.rb in storyblok-richtext-renderer-0.0.6
- old
+ new
@@ -5,12 +5,18 @@
def matching
@node['type'] === 'link'
end
def tag
+ attrs = @node['attrs']
+
+ if attrs['anchor'].is_a?(String) and !attrs['anchor'].empty?
+ attrs['href'] = "#{attrs['href']}##{attrs['anchor']}"
+ end
+
[{
tag: "a",
- attrs: @node['attrs'].slice('href', 'target')
+ attrs: attrs.slice('href', 'target')
}]
end
end
end
end