Skip to content

Commit fda2a02

Browse files
committed
Add canonical url to API docs
1 parent 43bc13c commit fda2a02

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

_lib/tasks/api_doc.rake

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace :api do
22
task :generate_docs do
3+
canonical_url = 'https://docs.knapsackpro.com/api/v1/'
34
raml2html = 'node_modules/raml2html/bin/raml2html'
45

56
raml_files = [
@@ -20,6 +21,12 @@ namespace :api do
2021
Kernel.system(cmd)
2122
exitstatus = $?.exitstatus
2223
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
29+
2330
puts "Compilation done for #{file[:src]}. Generated the #{file[:dest]} file."
2431
else
2532
puts "Something failed during RAML to HTML compilation for #{raml_file}."

0 commit comments

Comments
 (0)