Skip to content

Commit 30450da

Browse files
amartini51krilnon
andcommitted
Specialize the redirect pages.
This lets each page include a <meta> redirect to inform search engines what the corresponding URL in the new structure is. Co-authored-by: Kyle Murray <kyle_murray@apple.com>
1 parent 1354814 commit 30450da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3923
-49
lines changed

bin/publish-book

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,7 @@ docc convert \
4545
rm TSPL.docc/header.html
4646

4747

48-
# Copy the redirect page into every location where the legacy RST-based
48+
# Copy the redirect pages into every location where the legacy RST-based
4949
# pipeline created an HTML page, to keep links to those chapters and
5050
# sections working.
51-
52-
mkdir "$output"/GuidedTour
53-
mkdir "$output"/LanguageGuide
54-
mkdir "$output"/ReferenceManual
55-
mkdir "$output"/RevisionHistory
56-
57-
cp bin/redirect.html "$output"/GuidedTour/Compatibility.html
58-
cp bin/redirect.html "$output"/GuidedTour/GuidedTour.html
59-
cp bin/redirect.html "$output"/LanguageGuide/AccessControl.html
60-
cp bin/redirect.html "$output"/LanguageGuide/AdvancedOperators.html
61-
cp bin/redirect.html "$output"/LanguageGuide/AutomaticReferenceCounting.html
62-
cp bin/redirect.html "$output"/LanguageGuide/BasicOperators.html
63-
cp bin/redirect.html "$output"/LanguageGuide/ClassesAndStructures.html
64-
cp bin/redirect.html "$output"/LanguageGuide/Closures.html
65-
cp bin/redirect.html "$output"/LanguageGuide/CollectionTypes.html
66-
cp bin/redirect.html "$output"/LanguageGuide/Concurrency.html
67-
cp bin/redirect.html "$output"/LanguageGuide/ControlFlow.html
68-
cp bin/redirect.html "$output"/LanguageGuide/Deinitialization.html
69-
cp bin/redirect.html "$output"/LanguageGuide/Enumerations.html
70-
cp bin/redirect.html "$output"/LanguageGuide/ErrorHandling.html
71-
cp bin/redirect.html "$output"/LanguageGuide/Extensions.html
72-
cp bin/redirect.html "$output"/LanguageGuide/Functions.html
73-
cp bin/redirect.html "$output"/LanguageGuide/Generics.html
74-
cp bin/redirect.html "$output"/LanguageGuide/Inheritance.html
75-
cp bin/redirect.html "$output"/LanguageGuide/Initialization.html
76-
cp bin/redirect.html "$output"/LanguageGuide/MemorySafety.html
77-
cp bin/redirect.html "$output"/LanguageGuide/Methods.html
78-
cp bin/redirect.html "$output"/LanguageGuide/NestedTypes.html
79-
cp bin/redirect.html "$output"/LanguageGuide/OpaqueTypes.html
80-
cp bin/redirect.html "$output"/LanguageGuide/OptionalChaining.html
81-
cp bin/redirect.html "$output"/LanguageGuide/Properties.html
82-
cp bin/redirect.html "$output"/LanguageGuide/Protocols.html
83-
cp bin/redirect.html "$output"/LanguageGuide/StringsAndCharacters.html
84-
cp bin/redirect.html "$output"/LanguageGuide/Subscripts.html
85-
cp bin/redirect.html "$output"/LanguageGuide/TheBasics.html
86-
cp bin/redirect.html "$output"/LanguageGuide/TypeCasting.html
87-
cp bin/redirect.html "$output"/ReferenceManual/AboutTheLanguageReference.html
88-
cp bin/redirect.html "$output"/ReferenceManual/Attributes.html
89-
cp bin/redirect.html "$output"/ReferenceManual/Declarations.html
90-
cp bin/redirect.html "$output"/ReferenceManual/Expressions.html
91-
cp bin/redirect.html "$output"/ReferenceManual/GenericParametersAndArguments.html
92-
cp bin/redirect.html "$output"/ReferenceManual/LexicalStructure.html
93-
cp bin/redirect.html "$output"/ReferenceManual/Patterns.html
94-
cp bin/redirect.html "$output"/ReferenceManual/Statements.html
95-
cp bin/redirect.html "$output"/ReferenceManual/Types.html
96-
cp bin/redirect.html "$output"/ReferenceManual/zzSummaryOfTheGrammar.html
97-
cp bin/redirect.html "$output"/RevisionHistory/RevisionHistory.html
51+
cp -r bin/redirects/* "$output"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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/compatibility">
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+
const headingRedirects = {
21+
"#ID461": "guidedtour#Simple-Values",
22+
"#ID462": "guidedtour#Control-Flow",
23+
"#ID463": "guidedtour#Functions-and-Closures",
24+
}
25+
26+
const chapterRedirects = {
27+
"GuidedTour/GuidedTour.html": "guidedtour",
28+
"GuidedTour/AboutSwift.html": "aboutswift",
29+
"GuidedTour/Compatibility.html": "compatibility",
30+
"GuidedTour/GuidedTour.html": "guidedtour",
31+
"GuidedTour/GuidedTourPart.html": "guidedtour",
32+
33+
"LanguageGuide/AccessControl.html": "accesscontrol",
34+
"LanguageGuide/AdvancedOperators.html": "advancedoperators",
35+
"LanguageGuide/AutomaticReferenceCounting.html": "automaticreferencecounting",
36+
"LanguageGuide/BasicOperators.html": "basicoperators",
37+
"LanguageGuide/ClassesAndStructures.html": "classesandstructures",
38+
"LanguageGuide/Closures.html": "closures",
39+
"LanguageGuide/CollectionTypes.html": "collectiontypes",
40+
"LanguageGuide/Concurrency.html": "concurrency",
41+
"LanguageGuide/ControlFlow.html": "controlflow",
42+
"LanguageGuide/Deinitialization.html": "deinitialization",
43+
"LanguageGuide/Enumerations.html": "enumerations",
44+
"LanguageGuide/ErrorHandling.html": "errorhandling",
45+
"LanguageGuide/Extensions.html": "extensions",
46+
"LanguageGuide/Functions.html": "functions",
47+
"LanguageGuide/Generics.html": "generics",
48+
"LanguageGuide/Inheritance.html": "inheritance",
49+
"LanguageGuide/Initialization.html": "initialization",
50+
"LanguageGuide/LanguageGuidePart.html": "languageguide",
51+
"LanguageGuide/MemorySafety.html": "memorysafety",
52+
"LanguageGuide/Methods.html": "methods",
53+
"LanguageGuide/NestedTypes.html": "nestedtypes",
54+
"LanguageGuide/OpaqueTypes.html": "opaquetypes",
55+
"LanguageGuide/OptionalChaining.html": "optionalchaining",
56+
"LanguageGuide/Properties.html": "properties",
57+
"LanguageGuide/Protocols.html": "protocols",
58+
"LanguageGuide/StringsAndCharacters.html": "stringsandcharacters",
59+
"LanguageGuide/Subscripts.html": "subscripts",
60+
"LanguageGuide/TheBasics.html": "thebasics",
61+
"LanguageGuide/TypeCasting.html": "typecasting",
62+
63+
"ReferenceManual/AboutTheLanguageReference.html": "aboutthelanguagereference",
64+
"ReferenceManual/Attributes.html": "attributes",
65+
"ReferenceManual/Declarations.html": "declarations",
66+
"ReferenceManual/Expressions.html": "expressions",
67+
"ReferenceManual/GenericParametersAndArguments.html": "genericparametersandarguments",
68+
"ReferenceManual/LexicalStructure.html": "lexicalstructure",
69+
"ReferenceManual/Patterns.html": "patterns",
70+
"ReferenceManual/ReferenceManualPart.html": "referencemanual",
71+
"ReferenceManual/Statements.html": "statements",
72+
"ReferenceManual/Types.html": "types",
73+
"ReferenceManual/zzSummaryOfTheGrammar.html": "summaryofthegrammar",
74+
75+
"RevisionHistory/RevisionHistory.html": "revisionhistory",
76+
"RevisionHistory/RevisionHistoryPart.html": "revisionhistory",
77+
}
78+
79+
const path = window.location.pathname;
80+
const hash = window.location.hash;
81+
82+
var newURL = baseURL;
83+
if (hash == "") {
84+
const components = path.split("/");
85+
const part = components[components.length - 2];
86+
const chapter = components[components.length - 1];
87+
const redirectPath = chapterRedirects[part + "/" + chapter];
88+
newURL += redirectPath;
89+
} else {
90+
const redirectPath = headingRedirects[hash];
91+
newURL += redirectPath;
92+
}
93+
94+
document.getElementById("redirect").setAttribute("href", newURL);
95+
window.location = newURL;
96+
</script>
97+
</body>
98+
</html>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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/guidedtour">
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+
const headingRedirects = {
21+
"#ID461": "guidedtour#Simple-Values",
22+
"#ID462": "guidedtour#Control-Flow",
23+
"#ID463": "guidedtour#Functions-and-Closures",
24+
}
25+
26+
const chapterRedirects = {
27+
"GuidedTour/GuidedTour.html": "guidedtour",
28+
"GuidedTour/AboutSwift.html": "aboutswift",
29+
"GuidedTour/Compatibility.html": "compatibility",
30+
"GuidedTour/GuidedTour.html": "guidedtour",
31+
"GuidedTour/GuidedTourPart.html": "guidedtour",
32+
33+
"LanguageGuide/AccessControl.html": "accesscontrol",
34+
"LanguageGuide/AdvancedOperators.html": "advancedoperators",
35+
"LanguageGuide/AutomaticReferenceCounting.html": "automaticreferencecounting",
36+
"LanguageGuide/BasicOperators.html": "basicoperators",
37+
"LanguageGuide/ClassesAndStructures.html": "classesandstructures",
38+
"LanguageGuide/Closures.html": "closures",
39+
"LanguageGuide/CollectionTypes.html": "collectiontypes",
40+
"LanguageGuide/Concurrency.html": "concurrency",
41+
"LanguageGuide/ControlFlow.html": "controlflow",
42+
"LanguageGuide/Deinitialization.html": "deinitialization",
43+
"LanguageGuide/Enumerations.html": "enumerations",
44+
"LanguageGuide/ErrorHandling.html": "errorhandling",
45+
"LanguageGuide/Extensions.html": "extensions",
46+
"LanguageGuide/Functions.html": "functions",
47+
"LanguageGuide/Generics.html": "generics",
48+
"LanguageGuide/Inheritance.html": "inheritance",
49+
"LanguageGuide/Initialization.html": "initialization",
50+
"LanguageGuide/LanguageGuidePart.html": "languageguide",
51+
"LanguageGuide/MemorySafety.html": "memorysafety",
52+
"LanguageGuide/Methods.html": "methods",
53+
"LanguageGuide/NestedTypes.html": "nestedtypes",
54+
"LanguageGuide/OpaqueTypes.html": "opaquetypes",
55+
"LanguageGuide/OptionalChaining.html": "optionalchaining",
56+
"LanguageGuide/Properties.html": "properties",
57+
"LanguageGuide/Protocols.html": "protocols",
58+
"LanguageGuide/StringsAndCharacters.html": "stringsandcharacters",
59+
"LanguageGuide/Subscripts.html": "subscripts",
60+
"LanguageGuide/TheBasics.html": "thebasics",
61+
"LanguageGuide/TypeCasting.html": "typecasting",
62+
63+
"ReferenceManual/AboutTheLanguageReference.html": "aboutthelanguagereference",
64+
"ReferenceManual/Attributes.html": "attributes",
65+
"ReferenceManual/Declarations.html": "declarations",
66+
"ReferenceManual/Expressions.html": "expressions",
67+
"ReferenceManual/GenericParametersAndArguments.html": "genericparametersandarguments",
68+
"ReferenceManual/LexicalStructure.html": "lexicalstructure",
69+
"ReferenceManual/Patterns.html": "patterns",
70+
"ReferenceManual/ReferenceManualPart.html": "referencemanual",
71+
"ReferenceManual/Statements.html": "statements",
72+
"ReferenceManual/Types.html": "types",
73+
"ReferenceManual/zzSummaryOfTheGrammar.html": "summaryofthegrammar",
74+
75+
"RevisionHistory/RevisionHistory.html": "revisionhistory",
76+
"RevisionHistory/RevisionHistoryPart.html": "revisionhistory",
77+
}
78+
79+
const path = window.location.pathname;
80+
const hash = window.location.hash;
81+
82+
var newURL = baseURL;
83+
if (hash == "") {
84+
const components = path.split("/");
85+
const part = components[components.length - 2];
86+
const chapter = components[components.length - 1];
87+
const redirectPath = chapterRedirects[part + "/" + chapter];
88+
newURL += redirectPath;
89+
} else {
90+
const redirectPath = headingRedirects[hash];
91+
newURL += redirectPath;
92+
}
93+
94+
document.getElementById("redirect").setAttribute("href", newURL);
95+
window.location = newURL;
96+
</script>
97+
</body>
98+
</html>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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/accesscontrol">
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+
const headingRedirects = {
21+
"#ID461": "guidedtour#Simple-Values",
22+
"#ID462": "guidedtour#Control-Flow",
23+
"#ID463": "guidedtour#Functions-and-Closures",
24+
}
25+
26+
const chapterRedirects = {
27+
"GuidedTour/GuidedTour.html": "guidedtour",
28+
"GuidedTour/AboutSwift.html": "aboutswift",
29+
"GuidedTour/Compatibility.html": "compatibility",
30+
"GuidedTour/GuidedTour.html": "guidedtour",
31+
"GuidedTour/GuidedTourPart.html": "guidedtour",
32+
33+
"LanguageGuide/AccessControl.html": "accesscontrol",
34+
"LanguageGuide/AdvancedOperators.html": "advancedoperators",
35+
"LanguageGuide/AutomaticReferenceCounting.html": "automaticreferencecounting",
36+
"LanguageGuide/BasicOperators.html": "basicoperators",
37+
"LanguageGuide/ClassesAndStructures.html": "classesandstructures",
38+
"LanguageGuide/Closures.html": "closures",
39+
"LanguageGuide/CollectionTypes.html": "collectiontypes",
40+
"LanguageGuide/Concurrency.html": "concurrency",
41+
"LanguageGuide/ControlFlow.html": "controlflow",
42+
"LanguageGuide/Deinitialization.html": "deinitialization",
43+
"LanguageGuide/Enumerations.html": "enumerations",
44+
"LanguageGuide/ErrorHandling.html": "errorhandling",
45+
"LanguageGuide/Extensions.html": "extensions",
46+
"LanguageGuide/Functions.html": "functions",
47+
"LanguageGuide/Generics.html": "generics",
48+
"LanguageGuide/Inheritance.html": "inheritance",
49+
"LanguageGuide/Initialization.html": "initialization",
50+
"LanguageGuide/LanguageGuidePart.html": "languageguide",
51+
"LanguageGuide/MemorySafety.html": "memorysafety",
52+
"LanguageGuide/Methods.html": "methods",
53+
"LanguageGuide/NestedTypes.html": "nestedtypes",
54+
"LanguageGuide/OpaqueTypes.html": "opaquetypes",
55+
"LanguageGuide/OptionalChaining.html": "optionalchaining",
56+
"LanguageGuide/Properties.html": "properties",
57+
"LanguageGuide/Protocols.html": "protocols",
58+
"LanguageGuide/StringsAndCharacters.html": "stringsandcharacters",
59+
"LanguageGuide/Subscripts.html": "subscripts",
60+
"LanguageGuide/TheBasics.html": "thebasics",
61+
"LanguageGuide/TypeCasting.html": "typecasting",
62+
63+
"ReferenceManual/AboutTheLanguageReference.html": "aboutthelanguagereference",
64+
"ReferenceManual/Attributes.html": "attributes",
65+
"ReferenceManual/Declarations.html": "declarations",
66+
"ReferenceManual/Expressions.html": "expressions",
67+
"ReferenceManual/GenericParametersAndArguments.html": "genericparametersandarguments",
68+
"ReferenceManual/LexicalStructure.html": "lexicalstructure",
69+
"ReferenceManual/Patterns.html": "patterns",
70+
"ReferenceManual/ReferenceManualPart.html": "referencemanual",
71+
"ReferenceManual/Statements.html": "statements",
72+
"ReferenceManual/Types.html": "types",
73+
"ReferenceManual/zzSummaryOfTheGrammar.html": "summaryofthegrammar",
74+
75+
"RevisionHistory/RevisionHistory.html": "revisionhistory",
76+
"RevisionHistory/RevisionHistoryPart.html": "revisionhistory",
77+
}
78+
79+
const path = window.location.pathname;
80+
const hash = window.location.hash;
81+
82+
var newURL = baseURL;
83+
if (hash == "") {
84+
const components = path.split("/");
85+
const part = components[components.length - 2];
86+
const chapter = components[components.length - 1];
87+
const redirectPath = chapterRedirects[part + "/" + chapter];
88+
newURL += redirectPath;
89+
} else {
90+
const redirectPath = headingRedirects[hash];
91+
newURL += redirectPath;
92+
}
93+
94+
document.getElementById("redirect").setAttribute("href", newURL);
95+
window.location = newURL;
96+
</script>
97+
</body>
98+
</html>

0 commit comments

Comments
 (0)