blob: 125d11106cb39b9ca55a9dfc8b536327228be41d (
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
36
37
38
39
40
|
<% 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('/') %>
<link rel="canonical" href="<%= @config[:base_url] %><%= canonical_link %>" />
<meta property="og:url" content="<%= @config[:base_url] %><%= canonical_link %>" />
<% end %>
|