Skip to content

Commit 2a8cd2d

Browse files
committed
Add redirects for QR codes.
Includes adding a `latest` as a special version. Signed-off-by: Sam Barker <[email protected]>
1 parent 3f398a6 commit 2a8cd2d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

_data/redirects/qr-codes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
baseUrl: /documentation/
2+
delay: 60
3+
mappings:
4+
- name: current25-configuring-the-proxy
5+
fromVersion: 0.15.0
6+
path: /html/kroxylicious-proxy/#assembly-configuring-proxy-proxy
7+
- name: current25-operator
8+
fromVersion: 0.14.0
9+
path: /html/kroxylicious-operator/
10+
11+
12+

_plugins/redirector.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def generate(site)
1515
versions.each { |version|
1616
mapping['version'] = version
1717
site.pages << RedirectPage.new(site, redirect_config[0], redirect_config[1], mapping)
18+
if version == latest_release
19+
mapping['landing_version'] = "latest"
20+
site.pages << RedirectPage.new(site, redirect_config[0], redirect_config[1], mapping)
21+
end
1822
}
1923
end
2024
Jekyll.logger.info "Generated redirects #{redirect_config[0]}"
@@ -34,20 +38,20 @@ def known_releases(site)
3438

3539
# Subclass of `Jekyll::Page` with custom method definitions.
3640
class RedirectPage < Jekyll::Page
37-
def initialize(site, group, redirectConfig, mapping)
41+
def initialize(site, group, redirect_config, mapping)
3842

3943
@site = site # the current site instance.
4044
@base = site.source # path to the source directory.
41-
@dir = "/redirect/#{group}/#{mapping['version']}/" # the directory the page will reside in.
45+
@dir = "/redirect/#{group}/#{mapping['landing_version'] || mapping['version']}/" # the directory the page will reside in.
4246

4347
# All pages have the same filename, so define attributes straight away.
4448
@basename = mapping['name'] # filename without the extension.
4549
@ext = '.html' # the extension.
4650
@name = basename + ext # basically @basename + @ext.
4751
@layout = 'redirect.html'
48-
delay = redirectConfig['delay'] ||= 1
52+
delay = redirect_config['delay'] ||= 1
4953
@data = {
50-
'target' => "#{redirectConfig['baseUrl']}#{mapping['version']}#{mapping['path']}",
54+
'target' => "#{redirect_config['baseUrl']}#{mapping['version']}#{mapping['path']}",
5155
'layout' => 'redirect',
5256
'delay' => "#{delay}",
5357
}

0 commit comments

Comments
 (0)