Skip to content

Commit 95945de

Browse files
authored
Add a redirect at the top level (#336)
Without this redirect, the server generates a directory listing for <https://docs.swift.org/swift-book/documentation/> and you have to click through to the actual content. This page uses a reduced version of the existing redirect page, with the majority of the JavaScript removed. Because we never hosted any pre-DocC content at this URL, there's no reason to inspect the fragment and do a more specific redirect. There aren't any old URLs that point here for us to avoid breaking. Fixes: rdar://137038334
2 parents 1b663f7 + c331d12 commit 95945de

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

bin/publish-book

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ cp -r bin/redirects/LanguageGuide "$output"
5252
cp -r bin/redirects/ReferenceManual "$output"
5353
cp -r bin/redirects/RevisionHistory "$output"
5454
cp -r bin/redirects/index.html "$output"
55+
56+
# Add a redirect page from swift.org/swift-book/documentation/.
57+
cp -r bin/redirects/documentation/index.html "$output/documentation/"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<title>The Swift Programming Language: Redirect</title>
4+
<meta http-equiv="refresh" content="10; url=https://docs.swift.org/swift-book/documentation/the-swift-programming-language/">
5+
<head>
6+
<body>
7+
<div>
8+
This content has moved; redirecting to the
9+
<a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/" id="redirect">new location</a>.
10+
<noscript>
11+
<aside>
12+
This page requires JavaScript.
13+
Please turn on JavaScript and refresh the page.
14+
</aside>
15+
</noscript>
16+
</div>
17+
<script>
18+
const baseURL = "https://docs.swift.org/swift-book/documentation/the-swift-programming-language/";
19+
20+
var newURL = baseURL;
21+
22+
document.getElementById("redirect").setAttribute("href", newURL);
23+
window.location = newURL;
24+
</script>
25+
</body>
26+
</html>

bin/redirects/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<head>
33
<title>The Swift Programming Language: Redirect</title>
44
<meta http-equiv="refresh" content="10; url=https://docs.swift.org/swift-book/documentation/the-swift-programming-language/compatibility">
5-
<head>
5+
</head>
66
<body>
77
<div>
88
This content has moved; redirecting to the

0 commit comments

Comments
 (0)