Welcome to mirror list, hosted at ThFree Co, Russian Federation.

canonical_urls.html « layouts - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1b73967b05c25b718c50f7a71e21eab2be52d56d (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 ENV['NANOC_ENV'] == '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 %>