-
Notifications
You must be signed in to change notification settings - Fork 3
/
eleventy-redirect.njk
38 lines (38 loc) · 1.07 KB
/
eleventy-redirect.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---js
{
pagination: {
data: "collections.all",
size: 1,
alias: "redirect",
before: function (data) {
return data.reduce((redirects, page) => {
if (Array.isArray(page.data.redirect_from)) {
for (let url of page.data.redirect_from) {
redirects.push({ to: page.url, from: url });
}
} else if (typeof page.data.redirect_from === 'string') {
redirects.push({ to: page.url, from: page.data.redirect_from });
}
return redirects;
}, []);
},
addAllPagesToCollections: false,
},
permalink: "{{ redirect.from }}/index.html",
eleventyExcludeFromCollections: true,
}
---
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel=canonical href="{{ redirect.to | url }}">
<meta http-equiv=refresh content="0; url={{ redirect.to | url }}">
</head>
<body>
<h1>Redirecting...</h1>
<a href="{{ redirect.to | url }}">Click here if you are not redirected.</a>
<script>location='{{ redirect.to | url }}'</script>
</body>
</html>