Skip to content

Commit

Permalink
Programmatically add a redirect from /<plugin>/examples/ to the first
Browse files Browse the repository at this point in the history
example so we can link to that page from everywhere

It will also help with the redirects when the migration is over
  • Loading branch information
fabianrbz committed Dec 20, 2024
1 parent 4f41a7e commit a3cef26
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/_plugins/generators/redirects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class RefirectsGenerator < Jekyll::Generator

def generate(site)
redirects = api_specs_redirects(site)
redirects << plugin_examples_redirects(site)

site.pages << build_page(redirects, site)
end
Expand All @@ -22,5 +23,11 @@ def api_specs_redirects(site)
[page.data['base_url'], page.url].join("\t")
end
end

def plugin_examples_redirects(site)
site.data.fetch('kong_plugins', {}).map do |_slug, plugin|
["#{plugin.url}examples/", plugin.data.fetch('get_started_url')].join("\t")
end
end
end
end

0 comments on commit a3cef26

Please sign in to comment.