% if false %>
This is a comment!
Implement canonical links https://gitlab.com/gitlab-org/gitlab-docs/issues/167
We want to:
- All index.html and README.html files stripped
- Replace ce/ with ee/
------------------
if the link ends with 'README.md' or 'index.md'
strip 'README.md' or 'index.md'
else if link is '/index.erb'
use a single '/'
else
use the link and replace extension with '.html'
if the link starts with 'ce'
replace it with 'ee'
join indentifiers with '/' to form the canonical link
<% end %>
<% if production? %>
<% if (@item.identifier =~ /(index|README)\.md$/) == 0 %>
<% identifiers = @item.identifier.to_s.split('/') %>
<% identifiers[-1] = '' %>
<% elsif @item.identifier.to_s == '/index.erb' %>
<% identifiers = ['/'] %>
<% else %>
<% identifiers = @item.identifier.without_ext.to_s.split('/') %>
<% identifiers[-1] = identifiers[-1] + '.html' %>
<% end %>
<% if identifiers[1] == 'ce' %>
<% identifiers[1] = 'ee' %>
<% end %>
<% canonical_link = identifiers.join('/') %>
<% end %>