Skip to content

Commit 7795261

Browse files
committed
refactor: adding canonical to api
1 parent fda2a02 commit 7795261

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

_lib/tasks/api_doc.rake

+7-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ namespace :api do
2121
Kernel.system(cmd)
2222
exitstatus = $?.exitstatus
2323
if exitstatus.zero?
24-
html_contents = File.read(html_file)
25-
html_contents.gsub!('<head>', '<head><link rel="canonical" href="'+canonical_url+'" />')
26-
File.open(html_file, 'w') do |f|
27-
f.write(html_contents)
28-
end
24+
html = File
25+
.read(html_file)
26+
.gsub('<head>', <<~HEAD)
27+
<head><link rel="canonical" href="#{canonical_url}" />
28+
HEAD
29+
30+
File.open(html_file, 'w') { |f| f.write(html) }
2931

3032
puts "Compilation done for #{file[:src]}. Generated the #{file[:dest]} file."
3133
else

0 commit comments

Comments
 (0)