Skip to content

Commit dbc6605

Browse files
committed
Use root relative redirect paths and make absolute in layout
Why: I want to re-use the redirect layout from some HTML frontmatter, and you cannot use liquid templating nicely in the Jekyll frontmatter to create an absolute url like "target: {{"/path/to/target" | absolute_url}}". I want to use root relative paths so that it works when there is a base url. In future the layout would need adjustment if we wanted it to handle absolute redirect targets, maybe passing a different property to the page, or sniffing the first N characters for http:/https: Signed-off-by: Robert Young <[email protected]>
1 parent 52e8dcb commit dbc6605

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

_data/redirects/errors.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
baseUrl: https://kroxylicious.io/documentation/
1+
baseUrl: /documentation/
22
delay: 3
33
mappings:
44
- name: clientTls

_layouts/redirect.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!doctype html>
2+
{% assign absolute_target = page.target | absolute_url %}
23
<html lang="en">
34
<head>
45
<meta charset="utf-8">
@@ -13,13 +14,13 @@
1314
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"
1415
integrity="sha512-X/YkDZyjTf4wyc2Vy16YGCPHwAY8rZJY+POgokZjQB2mhIRFJCckEGc6YyX9eNsPfn0PzThEuNs+uaomE5CO6A=="
1516
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
16-
<meta http-equiv="refresh" content="{{ page.delay }}; url={{ page.target }}">
17+
<meta http-equiv="refresh" content="{{ page.delay }}; url={{ absolute_target }}">
1718
</head>
1819
<body class="d-flex flex-column min-vh-100" data-bs-theme="light">
1920
{% include nav.html %}
2021
<div class="container-fluid px-0 krx-content" data-bs-theme="light">
2122
<div class="paragraph" role="main">
22-
<div>Redirecting to <a href="{{ page.target }}">{{ page.target }}</a>...</div>
23+
<div>Redirecting to <a href="{{ absolute_target }}">{{ absolute_target }}</a>...</div>
2324
<div class="spinner-border text-success" role="status">
2425
<span class="visually-hidden">waiting...</span>
2526
</div>

0 commit comments

Comments
 (0)