class GovukTechDocs::Redirects
Constants
- LEADING_SLASH
Attributes
context[R]
Public Class Methods
new(context)
click to toggle source
# File lib/govuk_tech_docs/redirects.rb, line 5 def initialize(context) @context = context end
Public Instance Methods
redirects()
click to toggle source
# 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
Private Instance Methods
redirects_from_config()
click to toggle source
# File lib/govuk_tech_docs/redirects.rb, line 22 def redirects_from_config context.config[:tech_docs][:redirects].to_a end
redirects_from_frontmatter()
click to toggle source
# File lib/govuk_tech_docs/redirects.rb, line 26 def redirects_from_frontmatter reds = [] context.sitemap.resources.each do |page| next unless page.data.old_paths page.data.old_paths.each do |old_path| reds << [old_path, page.path] end end reds end