blob: 94a316ef720811018416bc76adfd9bfbbdf49e2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<% 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
if the link starts with ce
replace it with ee and strip README.md or index.md
if the link doesn't start with ce
strip README.md or index.md
if the link doesn't end with README.md or index.md
if the link starts with ce
replace it with ee
if the link doesn't start with ce
use its initial path
<% end %>
<% if is_production? %>
<% if (@item.identifier =~ /(index|README)\.md$/) == 0 %>
<% if @item.identifier.to_s.split('/')[1] == 'ce' %>
<link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.to_s.split('/')[2..-2].join('/') %><% unless @item.identifier.to_s.split('/')[2..-2].join('/').length == 0 %>/<% end %>" />
<% else %>
<link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.to_s.split('/')[0..-2].join('/') %>/" />
<% end %>
<% else %>
<% if @item.identifier.to_s.split('/')[1] == 'ce' %>
<link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.without_ext.to_s.split('/')[2..-1].join('/') + '.html' %>" />
<% elsif @item.identifier.to_s == '/index.erb' %>
<link rel="canonical" href="<%= @config[:base_url] %>/" />
<% else %>
<link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>" />
<% end %>
<% end %>
<% end %>
|