Class: GovukTechDocs::Redirects

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_tech_docs/redirects.rb

Constant Summary collapse

LEADING_SLASH =
%r{\A/}

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Redirects

Returns a new instance of Redirects.



5
6
7
# File 'lib/govuk_tech_docs/redirects.rb', line 5

def initialize(context)
  @context = context
end

Instance Method Details

#redirectsObject



9
10
11
12
13
14
15
16
# File 'lib/govuk_tech_docs/redirects.rb', line 9

def redirects
  all_redirects = redirects_from_config + redirects_from_frontmatter

  all_redirects.map do |from, to|
    # Middleman needs paths without leading slashes
    [from.sub(LEADING_SLASH, ""), { to: to.sub(LEADING_SLASH, "") }]
  end
end